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

Slash in route affects sorting/matching order #1265

Closed
nicolas-garcia opened this issue Dec 3, 2014 · 4 comments
Closed

Slash in route affects sorting/matching order #1265

nicolas-garcia opened this issue Dec 3, 2014 · 4 comments

Comments

@nicolas-garcia
Copy link

Hi !

I'm in trouble since a moment using Flask with that point.
I'm registring 2 url rules in a blueprint :

class MyClass(Blueprint):
    def setup(self):
        self.add_url_rule('<service>.<ext>', view_func=service_call)
        self.add_url_rule('networks.<ext>', view_func=networks)

I've read somewhere that the rule with the less number of parameters is taken in routing.
But, when I'm typing /networks.json, I'm in the service_call() function, not in networks()
When I print the url_map :

Map([ <Rule '/v1/<service>.<ext>' (HEAD, OPTIONS, GET) -> v1.service_call>,
 <Rule '/v1/networks.<ext>' (HEAD, OPTIONS, GET) -> v1.networks>,
 <Rule '/static/<filename>' (HEAD, OPTIONS, GET) -> static>])

After some tests, it seems that following code is working as expected :

class MyClass(Blueprint):
    def setup(self):
        self.add_url_rule('<service>/<ext>', view_func=service_call)
        self.add_url_rule('networks/<ext>', view_func=networks)

So, the dot isn't considered as a "separator" ?
Is there a way to fix that ?

Thanks in advance for your help !

@untitaker
Copy link
Contributor

Duplicate of pallets/werkzeug#185

@untitaker
Copy link
Contributor

Actually this is a slightly different case, so I'll reopen.

@untitaker untitaker reopened this Dec 3, 2014
@mreinhardt
Copy link

I think this is a Werkzeug issue, specifically with https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/routing.py. You should probably submit it to https://github.com/mitsuhiko/werkzeug/issues

In the meantime, reordering the routes should work.

@davidism davidism changed the title Url routing speciatization Order routes are registered affects how they are matched Jun 2, 2017
@davidism davidism changed the title Order routes are registered affects how they are matched Slash in route affects sorting/matching order Jun 4, 2017
@davidism
Copy link
Member

davidism commented Jun 5, 2017

This is a Werkzeug issue, already reported at pallets/werkzeug#727.

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

No branches or pull requests

4 participants