Skip to content

APP_BASE_HREF doesn't work with routes which starts with the same text part #45744

@Dolgovec

Description

@Dolgovec

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description

If route starts with the same part as APP_BASE_HREF, the route becomes broken. E.g.:

app.module

{
      provide: APP_BASE_HREF,
      useValue: '/ru'
    }

app-routing

{
    path: 'rules',
    loadChildren: () => import('./pages/text-pages/rules/rules.module').then(m => m.RulesModule)
  },

And if you try to navigate example.com/rules you will get example.com/ru/les

Please, take a look at the stackblitz reproduction below.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-68vpxc?file=src%2Fapp%2Fapp-routing.module.ts

Please provide the exception or error you saw

ERROR
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'les'
Error: Cannot match any routes. URL Segment: 'les'

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: commonIssues related to APIs in the @angular/common packagearea: router

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions