Skip to content

Commit 8832c99

Browse files
pkozlowski-opensourcegoderbauer
authored andcommitted
fix(UrlResolver): encode URLs before resolving
This commits makes JS implementation to behave like Dart one. Fixes angular#3543 Closes angular#3545
1 parent 9908c5f commit 8832c99

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

modules/angular2/src/services/url_resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function _joinAndCanonicalizePath(parts: List<any>): string {
272272
* @return {string}
273273
*/
274274
function _resolveUrl(base: string, url: string): string {
275-
var parts = _split(url);
275+
var parts = _split(encodeURI(url));
276276
var baseParts = _split(base);
277277

278278
if (isPresent(parts[_ComponentIndex.SCHEME])) {

modules/angular2/test/services/url_resolver_spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,13 @@ export function main() {
7070
expect(resolver.resolve('foo/baz/', '/bar')).toEqual('/bar');
7171
});
7272
});
73+
74+
describe('corner and error cases', () => {
75+
it('should encode URLs before resolving', () => {
76+
expect(resolver.resolve('foo/baz', `<p #p>Hello
77+
</p>`))
78+
.toEqual('foo/%3Cp%20#p%3EHello%0A%20%20%20%20%20%20%20%20%3C/p%3E');
79+
});
80+
});
7381
});
7482
}

0 commit comments

Comments
 (0)