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

Optional Parameters Trailing Slash no longer matched #1576

Closed
amcdnl opened this issue Nov 21, 2014 · 6 comments
Closed

Optional Parameters Trailing Slash no longer matched #1576

amcdnl opened this issue Nov 21, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@amcdnl
Copy link
Contributor

amcdnl commented Nov 21, 2014

After updating to 12 and 13, I'm getting unmatched params on the following route:

$stateProvider.state('record', {
    url: '/record/{appId}/{recordId:[0-9a-fA-F]{10,24}}',
    params: { 
        appId: { value: null },
        recordId: { value: null }
    },
    views:{
        '': {
            controller: 'RecordCtrl',
            templateUrl: 'app/record/record.tpl.html'
        }
    }
});

when I goto a url like:

 <a href="/myapp/record/546a3e4dd273c60780e35df3/">

per @christopherthielen this is because of the trailing slash introduced in the new version. Reference: #1032

@christopherthielen
Copy link
Contributor

This is due to the {10,24} in the recordId regex. Changing it to a "*" allows the pattern to match. See this failing test case I am adding:

      it("should populate even if the regexp requires 1 or more chars", function() {
        var m = new UrlMatcher('/record/{appId}/{recordId:[0-9a-fA-F]{10,24}}', {
          params: { appId: null, recordId: null }
        });
        expect(m.exec("/record/546a3e4dd273c60780e35df3/"))
          .toEqual({ appId: "546a3e4dd273c60780e35df3", recordId: null });
      });

@christopherthielen
Copy link
Contributor

I thought we accounted for this by making the capture group optional, but apparently it's not working how I think it is. Thanks for the bug report.

@christopherthielen christopherthielen added this to the 0.3.0 milestone Nov 21, 2014
@oleduc
Copy link

oleduc commented Nov 21, 2014

+1

1 similar comment
@bastienlau
Copy link

+1

@christopherthielen christopherthielen self-assigned this Nov 21, 2014
@christopherthielen
Copy link
Contributor

@amcdnl this matches your pattern

var m = new UrlMatcher('/record/{appId}/{recordId:[0-9a-fA-F]{10,24}}', {
params: { appId: null, recordId: { value: null, squash: true } }
});

granted, you shouldn't have to do this.

@amcdnl
Copy link
Contributor Author

amcdnl commented Feb 4, 2015

@christopherthielen I tried manually inserting this code and still no dice. I added the squash too.

Note: I'm using future states too, not sure if that has anything to do with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants