fix(common): Update Location to get a normalized URL valid in case a represented URL starts with the substring equals APP_BASE_HREF (#48394)

```ts
@NgModule({
  imports: [RouterModule.forRoot([{path: '/enigma', component: EnigmaComponent}])],
  providers: [{provide: APP_BASE_HREF, useValue: '/en'}]
})
export class AppModule {}
```

Navigating to `/enigma` will redirect to `/en/igma` not to `/en/enigma` as it expects

Fixes: #45744

PR Close #48394
This commit is contained in:
Konstantin Kharitonov
2022-12-08 01:01:55 +01:00
committed by Jessica Janiuk
parent caa1ad000e
commit d87285c363
2 changed files with 18 additions and 1 deletions
+4 -1
View File
@@ -301,7 +301,10 @@ export function createLocation() {
}
function _stripBasePath(basePath: string, url: string): string {
return basePath && url.startsWith(basePath) ? url.substring(basePath.length) : url;
if (basePath === url) {
return '';
}
return basePath && url.startsWith(basePath + '/') ? url.substring(basePath.length) : url;
}
function _stripIndexHtml(url: string): string {