Skip to content

Commit

Permalink
fix(UrlResolver): encode URLs before resolving
Browse files Browse the repository at this point in the history
This commits makes JS implementation to behave like Dart one.

Fixes angular#3543

Closes angular#3545
  • Loading branch information
pkozlowski-opensource authored and goderbauer committed Aug 15, 2015
1 parent 9908c5f commit 8832c99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/angular2/src/services/url_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function _joinAndCanonicalizePath(parts: List<any>): string {
* @return {string}
*/
function _resolveUrl(base: string, url: string): string {
var parts = _split(url);
var parts = _split(encodeURI(url));
var baseParts = _split(base);

if (isPresent(parts[_ComponentIndex.SCHEME])) {
Expand Down
8 changes: 8 additions & 0 deletions modules/angular2/test/services/url_resolver_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,13 @@ export function main() {
expect(resolver.resolve('foo/baz/', '/bar')).toEqual('/bar');
});
});

describe('corner and error cases', () => {
it('should encode URLs before resolving', () => {
expect(resolver.resolve('foo/baz', `<p #p>Hello
</p>`))
.toEqual('foo/%3Cp%20#p%3EHello%0A%20%20%20%20%20%20%20%20%3C/p%3E');
});
});
});
}

0 comments on commit 8832c99

Please sign in to comment.