Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
f6b352ee
...
f6b352ee0ec3d77d16323ae8c3b704161163fe4f
authored
2013-08-05 16:32:48 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed #565 - undefined response when unicode URL
1 parent
e6e192ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
9 deletions
modules/casper.js
modules/utils.js
tests/suites/utils.js
modules/casper.js
View file @
f6b352e
...
...
@@ -938,15 +938,9 @@ Casper.prototype.getPageContent = function getPageContent() {
Casper
.
prototype
.
getCurrentUrl
=
function
getCurrentUrl
()
{
"use strict"
;
this
.
checkStarted
();
var
url
=
this
.
evaluate
(
function
_evaluate
()
{
return
utils
.
decodeUrl
(
this
.
evaluate
(
function
_evaluate
()
{
return
document
.
location
.
href
;
});
try
{
return
decodeURIComponent
(
url
);
}
catch
(
e
)
{
/*global unescape*/
return
unescape
(
url
);
}
}));
};
/**
...
...
@@ -1151,7 +1145,7 @@ Casper.prototype.handleReceivedResource = function(resource) {
return
;
}
this
.
resources
.
push
(
resource
);
if
(
resource
.
url
!==
this
.
requestUrl
)
{
if
(
utils
.
decodeUrl
(
resource
.
url
)
!==
this
.
requestUrl
)
{
return
;
}
this
.
currentHTTPStatus
=
null
;
...
...
modules/utils.js
View file @
f6b352e
...
...
@@ -124,6 +124,22 @@ function computeModifier(modifierString, modifiers) {
exports
.
computeModifier
=
computeModifier
;
/**
* Decodes a URL.
* @param String url
* @return String
*/
function
decodeUrl
(
url
)
{
"use strict"
;
try
{
return
decodeURIComponent
(
url
);
}
catch
(
e
)
{
/*global unescape*/
return
unescape
(
url
);
}
}
exports
.
decodeUrl
=
decodeUrl
;
/**
* Dumps a JSON representation of passed value to the console. Used for
* debugging purpose only.
*
...
...
tests/suites/utils.js
View file @
f6b352e
...
...
@@ -75,6 +75,15 @@ if (utils.gteVersion(phantom.version, '1.9.0')) {
});
}
casper
.
test
.
begin
(
'decodeUrl() tests'
,
4
,
function
(
test
)
{
/* global escape */
test
.
assertEquals
(
utils
.
decodeUrl
(
'foo'
),
'foo'
);
test
.
assertEquals
(
utils
.
decodeUrl
(
'Forlì'
),
'Forlì'
);
test
.
assertEquals
(
utils
.
decodeUrl
(
encodeURIComponent
(
'Forlì'
)),
'Forlì'
);
test
.
assertEquals
(
utils
.
decodeUrl
(
escape
(
'Forlì'
)),
'Forlì'
);
test
.
done
();
});
casper
.
test
.
begin
(
'equals() tests'
,
23
,
function
(
test
)
{
test
.
assert
(
utils
.
equals
(
null
,
null
),
'equals() null equality'
);
test
.
assertNot
(
utils
.
equals
(
null
,
undefined
),
'equals() null vs. undefined inequality'
);
...
...
Please
register
or
sign in
to post a comment