Skip to content

The (needed) "index.html" disappears from Location URL upon page refresh or direct navigation #19296

Open

Description

@cmpilato

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I don't have a ready-made reproduction (sorry, too new at this), but I'm working with a team of folks on a version control repository (Git/Subversion) viewer type of application (rather like the GitHub code browser) where the repository path to be viewed is carried in the Angular app's route URL. For example, the repository path of a Subversion-versioned project's website index file might be /trunk/www/index.html, and the Angular app's route for displaying the contents of that file might be {{base_href}}/{{project_name}}/view/trunk/www/index.html.

Note firstly that this all works as expected for most versioned items. But for paths that actually end in the literal string index.html, Angular eats that bit of the location URL and the app shows the parent directory instead. Now, from the parent directory display of my app (which shows as a directory listing with each subdirectory and file linked, as expected), I can navigate into an index.html repository file's display successfully. But if I refresh the page, I see the Location URL change to have the index.html removed and my app again shows the parent directory listing.

I suspect this may have something to do with this logic in Location's constructor, but lack the skillz to prove it:

this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));

Expected behavior

I expect that the index.html part of a Location URL would be left in place and available to the router and components that need it.

Environment


Angular version: 4.3.5

Browser:
- [X] Chromium (desktop) version 60.0.3112.113
 

Activity

  1. cmpilato commented on Nov 29, 2017

    @cmpilato
    Author

    I have confirmed that this remains a bug in Angular 5.0.1.

  2. cmpilato commented on Nov 29, 2017

    @cmpilato
    Author

    It does appear, though, that as workaround, I can enter the URL using percent encoding for the slashes in the "path" part of route:

    {{base_href}}/{{project_name}}/view/trunk%2Fwww%2Findex.html

  3. jasonaden commented on Dec 5, 2017

    @jasonaden
    Contributor

    Interesting. Thanks for logging the issue.

    For a reproduction, you can use the following. It would be good to have one available, and you should be able to create it pretty quickly using one of the following links:

    We suggest using StackBlitz or Plunker.

  4. added this to the Backlog milestone on Jan 23, 2018
  5. modified the milestones: Backlog, needsTriage on Feb 26, 2018
  6. guedeWebGate commented on Sep 18, 2018

    @guedeWebGate

    Any plan to fix this?

  7. webdevelopland commented on Feb 10, 2020

    @webdevelopland

    I faced the same issue.
    @jasonaden Here's the reproduction:
    https://stackblitz.com/edit/angular-gitter-vxwxph
    When we try ?path=folder/index.html as param, path becomes folder, index.html disappears.

  8. hermannloose commented on Feb 24, 2020

    @hermannloose

    @jasonaden _stripIndexHtml() which appears to cause this nowadays seems to have been added in ec455e1 last April by you, although probably recreating existing behavior? Do you know if this can be removed without breaking a lot of existing Angular apps? I am working on a version control file viewing application similar to the OP, where it's important to preserve the full URL.

  9. added
    area: upgrade
    on Jul 8, 2020
  10. removed
    area: upgrade
    on Jul 10, 2020
  11. added
    P3
    and removed on Oct 1, 2020
  12. kdb13 commented on Jul 10, 2025

    @kdb13

    Has anyone found a workaround for this issue until it gets fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: routerfreq1: lowrouter: URL parsing/generationstate: confirmedtype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions