Skip to content

Relative link routing with empty paths are not working #30437

Closed

Description

@bharathiram

🐞 Bug report

  • Relative urls are not working as expected for empty paths when navigate between parent-child routes in the lazy loaded modules
  • Relative urls are not working as expected for empty paths when navigate between parent-child routes in the eager loaded modules as well

Affected Package

The issue is caused by package @angular/router

Description

  • Navigate to child-component (./child1-component)
  • Navigate back to parent (../)
  • Navigate to child-component again (./child1-component).
  • But it tries to navigate to "//child1-component" & throws an error
Routes in app module (forRoot)
const routes: Routes = [
  { 
    path: '',
    loadChildren: 'app/lazy/lazy.module#LazyModule' 
  },
];
Lazy loaded module routes (forChild)
const routes: Routes = [
  {
    path: '',
    component: LazyComponent,
    children: [
      {
        path: 'child1-component',
        component: BComponent
      },
      {
        path: 'child2-component',
        component: CComponent
      },
    ]
  }
];

🔬 Minimal Reproduction

Lazy Loading: https://stackblitz.com/edit/relative-link-lazy-loading
Eager Loading: https://stackblitz.com/edit/relative-link-eager-loading

🔥 Exception or Error

Error: Uncaught (in promise): SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'https://%28child1-component%29/' cannot be created in a document with origin 'https://relative-link-lazy-loading.stackblitz.io' and URL 'https://relative-link-lazy-loading.stackblitz.io/'.

🌍 Your Environment


Angular CLI: 7.3.3
Node: 10.8.0
OS: darwin x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

**Angular Version:**
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.3
@angular/cdk                      7.3.7
@angular/cli                      7.3.3
@angular/material                 7.3.7

Anything else relevant?
No

UPDATE:

It is not specific to lazy loading. I can reproduce the same empty path issue with eager loading as well

https://stackblitz.com/edit/relative-link-eager-loading

Activity

  1. changed the title [-]Relative link routing in the lazyloaded modules with empty paths is not working[/-] [+]Relative link routing in the lazyloaded modules with empty paths are not working[/+] on May 13, 2019
  2. changed the title [-]Relative link routing in the lazyloaded modules with empty paths are not working[/-] [+]Relative link routing in a lazyloaded module with empty paths are not working[/+] on May 13, 2019
  3. added this to the needsTriage milestone on May 14, 2019
  4. modified the milestones: needsTriage, Backlog on May 14, 2019
  5. changed the title [-]Relative link routing in a lazyloaded module with empty paths are not working[/-] [+]Relative link routing with empty paths are not working[/+] on May 16, 2019
  6. kioviensis commented on May 18, 2019

    @kioviensis

    After debugging, I found out that UrlTree is different

    Before (first attempt to navigate to ./child1-component

    image

    After (other attempts to navigate to ./child1-component

    image

    So, after second navigation, we got changed UrlTree and +1 nested UrlSegmentGroup
    That is a reason, why it trapped into the third condition of serializeSegment

  7. atscott commented on May 29, 2020

    @atscott
    Contributor

    Closing as duplicate of #35687
    Related/duplicates:
    #13011
    #18059
    #19290
    #35687

  8. angular-automatic-lock-bot commented on Jun 30, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions