fix(UrlResolver): encode URLs before resolving

This commits makes JS implementation to behave like Dart one.

Fixes #3543

Closes #3545
This commit is contained in:
Pawel Kozlowski 2015-08-08 09:25:24 +02:00
parent 86eb46af09
commit 4f5e405676
2 changed files with 9 additions and 1 deletions

View File

@ -272,7 +272,7 @@ function _joinAndCanonicalizePath(parts: List<any>): string {
* @return {string} * @return {string}
*/ */
function _resolveUrl(base: string, url: string): string { function _resolveUrl(base: string, url: string): string {
var parts = _split(url); var parts = _split(encodeURI(url));
var baseParts = _split(base); var baseParts = _split(base);
if (isPresent(parts[_ComponentIndex.SCHEME])) { if (isPresent(parts[_ComponentIndex.SCHEME])) {

View File

@ -70,5 +70,13 @@ export function main() {
expect(resolver.resolve('foo/baz/', '/bar')).toEqual('/bar'); 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');
});
});
}); });
} }