Skip to content

properly anchor ends of url patterns #697

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

Merged
merged 3 commits into from
Aug 31, 2019

Conversation

n2ygk
Copy link
Contributor

@n2ygk n2ygk commented Aug 30, 2019

Description of the Change

The example usage of url() in example/urls.py and example/urls_test.py was missing
the $ anchor at the end of most patterns. Best practice is to fully specify an anchored URL to avoid inadvertently matching a substring.

For example: url(r'foo/bar') will match /foo/bar but also /foo/barf.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added (existing unit tests continue to work)
  • documentation updated (all doc examples already had $ anchors)
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@codecov
Copy link

codecov bot commented Aug 31, 2019

Codecov Report

Merging #697 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #697   +/-   ##
=======================================
  Coverage   95.97%   95.97%           
=======================================
  Files          54       54           
  Lines        2735     2735           
=======================================
  Hits         2625     2625           
  Misses        110      110
Impacted Files Coverage Δ
example/urls_test.py 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd8b535...b52e09e. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 31, 2019

Codecov Report

Merging #697 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #697   +/-   ##
=======================================
  Coverage   95.97%   95.97%           
=======================================
  Files          54       54           
  Lines        2735     2735           
=======================================
  Hits         2625     2625           
  Misses        110      110
Impacted Files Coverage Δ
example/urls_test.py 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 189fdfe...8171a86. Read the comment docs.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @n2ygk it's great to split out as much as possible from #689 into different PRs. Removed changelog entry though as I think this change is not relevant to current DJA users but only for new users which will start with the example app anyway.

@sliverc sliverc merged commit a9427d6 into django-json-api:master Aug 31, 2019
@n2ygk
Copy link
Contributor Author

n2ygk commented Sep 3, 2019

...Removed changelog entry though as I think this change is not relevant to current DJA users but only for new users which will start with the example app anyway.

@sliverc Not a big deal, but I expect existing users trying to use the new generateschema functionality will be burned if their code follows the examples and lacks $ or / due to the django simplify_regex bug fix: django/django#11728 which likely won't appear until Django 3.0.

@n2ygk n2ygk deleted the anchor_urls branch September 3, 2019 16:43
@sliverc
Copy link
Member

sliverc commented Sep 3, 2019

@n2ygk this is properly better explained in the documentation of generateschema as someone not having based its urls.py on the example app might have the exact same issue as well.

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

Successfully merging this pull request may close these issues.

3 participants