mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jessica Janiuk
parent
caa1ad000e
commit
d87285c363
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user