Skip to content

LocationUpgradeModule throws Unhandled Navigation Error on initialisation when useHash is set to true #31882

@francis-shine

Description

@francis-shine

🐞 bug report

Affected Package

The issue is caused by package @angular/common/upgrade

Is this a regression?

No, the feature on which this was built was introduced in Angular 8

Description

When useHash is set to true using the newly introduced LocationUpgradeModule, Angular routing fails to initialise. This appears to be caused by the private $$parse method in location_shim.ts, which is being called with urls containing an unexpected # prefix (the current code only checks for a / prefix

🔬 Minimal Reproduction

https://angular-issue-repro2-3bkm6g.stackblitz.io

🔥 Exception or Error

The initial console error is:


Unhandled Navigation Error:

Using the debugger to drill down into the code to reveal the actual error:


Invalid url "#/", missing path prefix "https://angular-issue-repro2-3bkm6g.stackblitz.io/".

🌍 Your Environment

Angular Version:


Angular CLI: 8.1.2
Node: 10.15.0
OS: darwin x64
Angular: 8.1.3
... common, compiler, compiler-cli, core, language-service
... platform-browser, platform-browser-dynamic, router, upgrade

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.2
@angular-devkit/build-angular     0.801.2
@angular-devkit/build-optimizer   0.801.2
@angular-devkit/build-webpack     0.801.2
@angular-devkit/core              8.1.2
@angular-devkit/schematics        8.1.2
@angular/cli                      8.1.2
@ngtools/webpack                  8.1.2
@schematics/angular               8.1.2
@schematics/update                0.801.2
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.35.2

Anything else relevant?

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: upgradeIssues related to AngularJS → Angular upgrade APIsfreq1: lowstate: confirmedtype: bug/fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions