Commit ace3fe08 ace3fe0842bdea3aad29410a4126dcc81354b049 by Nicolas Perriault

fixed Casper.getCurrentUrl() could misbehave with encoded urls

1 parent 96652285
......@@ -7,6 +7,7 @@ XXXX-XX-XX, v1.0.0
This version is yet to be released.
- fixed [#259](https://github.com/n1k0/casperjs/issues/259) - enhanced `Tester.assertField()` method, which can now tests for other field types than `input`s.
- fixed `Casper.getCurrentUrl()` could misbehave with encoded urls
- added [`Casper.echo()`](http://casperjs.org/api.html#clientutils.echo) to print a message to the casper console from the remote DOM environment
- added [`Casper.waitForText()`](http://casperjs.org/api.html#casper.waitForText) to wait for a given text to be present in page HTML contents
- added [`ClientUtils.getFieldValue()`](http://casperjs.org/api.html#clientutils.getFieldValue)
......
......@@ -758,7 +758,8 @@ Casper.prototype.getCurrentUrl = function getCurrentUrl() {
try {
return decodeURIComponent(url);
} catch (e) {
return url;
/*global unescape*/
return unescape(url);
}
};
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CasperJS url tests</title>
</head>
<body>
<ul>
<li><a href="?test=Forlì">raw unicode</a></li>
<li><a href="?test=Forl%EC">escaped</a></li>
<li><a href="?test=Forl%C3%AC">uri encoded</a></li>
</ul>
</body>
</html>
/*global casper*/
/*jshint strict:false*/
casper.start('tests/site/urls.html', function() {
this.clickLabel('raw unicode', 'a');
}).then(function() {
this.test.assertHttpStatus(200);
this.test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a raw unicode URL');
this.clickLabel('escaped', 'a');
});
casper.then(function() {
this.test.assertHttpStatus(200);
this.test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves an escaped URL');
this.clickLabel('uri encoded', 'a');
});
casper.run(function() {
this.test.assertHttpStatus(200);
this.test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a decoded URL');
this.test.done();
});