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

BUG: regex pattern keeps in endpoint #507

Closed
jtamm-red opened this issue Sep 7, 2021 · 5 comments
Closed

BUG: regex pattern keeps in endpoint #507

jtamm-red opened this issue Sep 7, 2021 · 5 comments
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@jtamm-red
Copy link
Contributor

jtamm-red commented Sep 7, 2021

urlpatterns = [
    url('^file/(?P<filename>.*)\\.(?P<ext>\\w+)$', get_file)
]

image

Endpoint should be ​/file​/{filename}.{ext}. Possible generate from pattern to text (ex: "\" is removed) .

@tfranzel tfranzel added bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending labels Sep 7, 2021
@tfranzel
Copy link
Owner

tfranzel commented Sep 7, 2021

excellent find! simplify_regex from Django (which is used by DRF) apparently missed that case.

@jtamm-red
Copy link
Contributor Author

Removing of regex pattern is not solved yet.

urlpatterns = [
    url('^service/(?P<code>[a-zA-Z0-9_\\-]+)/(?P<path>.*)', do_service)
]

image

Endpoint should be "/service/{code}/{path}"

@tfranzel
Copy link
Owner

i cannot reproduce your example. i extended the new test test_literal_dot_in_regex_path and it worked fine

...
urlpatterns = [
    url('^service/(?P<code>[a-zA-Z0-9_\\-]+)/(?P<path>.*)', view_func)
]
....
assert '/service/{code}/{path}' in schema['paths']

are you on current master?

@tfranzel
Copy link
Owner

this may be an issue with 'Django==2.2' or rather before version '3'. they had another bug in simplify_regex that was fixed 3 years ago. the problem it produced looked very similar to this.

@jtamm-red
Copy link
Contributor Author

I got it. I am using django version 2.2.24. I have to move latest version.This old version will be no longer supported on next year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants