Skip to content

Strip trailing slash doesn't take into account query or hash in the url #14905

@diestrin

Description

@diestrin

I'm submitting a ...

[x] bug report

Current behavior
The Location class is removing the trailing slash, but it's just looking at the end of the string and the string might contain the query and hash values. Currently if you have a a trailing slash and a query parameter, the trailing slash is not being removed.

Expected behavior
The Location::stripTrailingSlash should take care of remove the trailing slash even if the query or hash are present.

Minimal reproduction of the problem with instructions
Given the route definition { path: '/test', pathMatch: 'full' }
This is the result:

/test => Works
/test/ => Works, rewrites browser url to /test
/test/?a=b => Error, doesn't find the route

What is the motivation / use case for changing the behavior?
It's a bug and causes routes not to work properly

  • Angular version: 2.1.2
    Checked the regex in master branch and it's still the same as in 2.1.2

  • Browser: [all]

  • Language: [all]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions