fix(router): respect LocationStrategy when constructing hrefs in links
Note that this introduces more behavior for LocationStrategy which needs yet more refactoring to test. See #4935. Closes #4333
This commit is contained in:
@ -21,10 +21,15 @@ export class SpyLocation implements Location {
|
||||
|
||||
simulateUrlPop(pathname: string) { ObservableWrapper.callNext(this._subject, {'url': pathname}); }
|
||||
|
||||
normalizeAbsolutely(url: string): string { return this._baseHref + url; }
|
||||
prepareExternalUrl(url: string): string {
|
||||
if (url.length > 0 && !url.startsWith('/')) {
|
||||
url = '/' + url;
|
||||
}
|
||||
return this._baseHref + url;
|
||||
}
|
||||
|
||||
go(path: string, query: string = '') {
|
||||
path = this.normalizeAbsolutely(path);
|
||||
path = this.prepareExternalUrl(path);
|
||||
if (this._path == path && this._query == query) {
|
||||
return;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ export class MockLocationStrategy extends LocationStrategy {
|
||||
|
||||
path(): string { return this.internalPath; }
|
||||
|
||||
prepareExternalUrl(internal: string): string { return internal; }
|
||||
|
||||
simulateUrlPop(pathname: string): void {
|
||||
ObservableWrapper.callNext(this._subject, {'url': pathname});
|
||||
}
|
||||
|
Reference in New Issue
Block a user