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