Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash does not remove trailing slash in ui-sref #2299

Closed
ritenv opened this issue Oct 7, 2015 · 5 comments
Closed

Squash does not remove trailing slash in ui-sref #2299

ritenv opened this issue Oct 7, 2015 · 5 comments

Comments

@ritenv
Copy link

ritenv commented Oct 7, 2015

If I define a state as below:

    $stateProvider.state('productsByCategory', {
        url: '/products/:catSlug/:subCatSlug?',
        controller: 'MyController',
        params: {subCatSlug: {value:null, squash: true}},
        templateUrl: '/app/products/list.html'
    })

I expect this to match the URL path /products/watches, which it does (no trailing slash).

However, if I do the below methods, I get the URLs with the trailing slashes:

    <a ui-sref="productsByCategory({catSlug: 'watches'})">Go to Watches</a>

I get the below compiled tag:

    <a ui-sref="/products/watches/">Go to Watches</a>

(The slash is not squashed)

Is this an expected behavior? And if so, is there a way to retrieve the squashed version via ui-sref?

@wesleycho
Copy link
Contributor

Here is a reproduction - this appears to be a bug.

@nateabele nateabele added the bug label Oct 13, 2015
@adamreisnz
Copy link

+1

@nateabele this was flagged as a bug on October 2015, it doesn't seem like a very complicated thing to fix. Any chance someone could have a look at it?

@wesleycho
Copy link
Contributor

You could always file a PR :)

@adamreisnz
Copy link

adamreisnz commented Jun 20, 2016

This seems to be related to (or the same as) #1902 which appears to have been fixed already in August last year, the changelog says version 0.2.16 (2016-01-24). However, it's not functioning anymore as it should in 0.3.0.

@wesleycho I've taken a look at the source code, and it seems this test is wrong as it has a trailing slash in the /users/: https://github.com/angular-ui/ui-router/blob/legacy/test/urlMatcherFactorySpec.js#L731

I've looked at the code in the urlMatcherFactory but the code is poorly documented and it would take me a while to figure out where all the data sits and how it all fits together. Someone with a better understanding of the internal workings of ui-router could probably spot the problem very quickly.

Is there anyone on the team with a couple of minutes to spare to have a look into this? It seems the issue has been addressed once before, so that would be a good starting point.

@stale
Copy link

stale bot commented Jan 24, 2020

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues
may be reopened.

Thank you for your contributions.

@stale stale bot added the stale label Jan 24, 2020
@stale stale bot closed this as completed Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants