Skip to content

Commit

Permalink
adapt createHref instead of prependBasePath
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Apr 7, 2020
1 parent eff1faf commit e4b8eeb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/core/public/application/scoped_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,17 @@ export class ScopedHistory<HistoryLocationState = unknown>
prependBasePath: boolean = true
): Href => {
this.verifyActive();
return this.parentHistory.createHref(
prependBasePath ? this.prependBasePath(location) : location
);
if (prependBasePath) {
location = this.prependBasePath(location);
if (location.pathname === undefined) {
// we always want to create an url relative to the basePath
// so if pathname is not present, we use the history's basePath as default
// we are doing that here because `prependBasePath` should not
// alter pathname for other method calls
location.pathname = this.basePath;
}
}
return this.parentHistory.createHref(location);
};

private prependBasePath(path: Path): Path;
Expand All @@ -252,7 +260,7 @@ export class ScopedHistory<HistoryLocationState = unknown>
pathname:
pathOrLocation.pathname !== undefined
? this.prependBasePathToString(pathOrLocation.pathname)
: this.basePath,
: undefined,
};
}
}
Expand Down

0 comments on commit e4b8eeb

Please sign in to comment.