From 93c8852c2a32c8a782b8746039683d00c83a6e14 Mon Sep 17 00:00:00 2001 From: Alan Crosswell Date: Fri, 30 Aug 2019 13:12:56 -0400 Subject: [PATCH 1/2] properly anchor urls --- CHANGELOG.md | 1 + example/urls.py | 18 +++++++++--------- example/urls_test.py | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b658b20..53c21753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This release is not backwards compatible. For easy migration best upgrade first `JSON_API_PLURALIZE_RELATION_TYPE` * Removed obsolete util methods `format_keys` and `format_relation_name` * Removed obsolete pagination classes `PageNumberPagination` and `LimitOffsetPagination` +* Added `$` anchor to example urls to use the best practice of having a full URL match. ### Fixed diff --git a/example/urls.py b/example/urls.py index 79d3b1c1..72788060 100644 --- a/example/urls.py +++ b/example/urls.py @@ -30,20 +30,20 @@ urlpatterns = [ url(r'^', include(router.urls)), - url(r'^entries/(?P[^/.]+)/suggested/', + url(r'^entries/(?P[^/.]+)/suggested/$', EntryViewSet.as_view({'get': 'list'}), name='entry-suggested' ), - url(r'entries/(?P[^/.]+)/blog', + url(r'entries/(?P[^/.]+)/blog$', BlogViewSet.as_view({'get': 'retrieve'}), name='entry-blog'), - url(r'entries/(?P[^/.]+)/comments', + url(r'entries/(?P[^/.]+)/comments$', CommentViewSet.as_view({'get': 'list'}), name='entry-comments'), - url(r'entries/(?P[^/.]+)/authors', + url(r'entries/(?P[^/.]+)/authors$', AuthorViewSet.as_view({'get': 'list'}), name='entry-authors'), - url(r'entries/(?P[^/.]+)/featured', + url(r'entries/(?P[^/.]+)/featured$', EntryViewSet.as_view({'get': 'retrieve'}), name='entry-featured'), @@ -51,16 +51,16 @@ AuthorViewSet.as_view({'get': 'retrieve_related'}), name='author-related'), - url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)$', EntryRelationshipView.as_view(), name='entry-relationships'), - url(r'^blogs/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^blogs/(?P[^/.]+)/relationships/(?P\w+)$', BlogRelationshipView.as_view(), name='blog-relationships'), - url(r'^comments/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^comments/(?P[^/.]+)/relationships/(?P\w+)$', CommentRelationshipView.as_view(), name='comment-relationships'), - url(r'^authors/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^authors/(?P[^/.]+)/relationships/(?P\w+)$', AuthorRelationshipView.as_view(), name='author-relationships'), ] diff --git a/example/urls_test.py b/example/urls_test.py index e51121ac..020ab2f3 100644 --- a/example/urls_test.py +++ b/example/urls_test.py @@ -44,30 +44,30 @@ url(r'^', include(router.urls)), # old tests - url(r'identities/default/(?P\d+)', + url(r'identities/default/(?P\d+)$', GenericIdentity.as_view(), name='user-default'), - url(r'^entries/(?P[^/.]+)/blog', + url(r'^entries/(?P[^/.]+)/blog$', BlogViewSet.as_view({'get': 'retrieve'}), name='entry-blog' ), - url(r'^entries/(?P[^/.]+)/comments', + url(r'^entries/(?P[^/.]+)/comments$', CommentViewSet.as_view({'get': 'list'}), name='entry-comments' ), - url(r'^entries/(?P[^/.]+)/suggested/', + url(r'^entries/(?P[^/.]+)/suggested/$', EntryViewSet.as_view({'get': 'list'}), name='entry-suggested' ), - url(r'^drf-entries/(?P[^/.]+)/suggested/', + url(r'^drf-entries/(?P[^/.]+)/suggested/$', DRFEntryViewSet.as_view({'get': 'list'}), name='drf-entry-suggested' ), - url(r'entries/(?P[^/.]+)/authors', + url(r'entries/(?P[^/.]+)/authors$', AuthorViewSet.as_view({'get': 'list'}), name='entry-authors'), - url(r'entries/(?P[^/.]+)/featured', + url(r'entries/(?P[^/.]+)/featured$', EntryViewSet.as_view({'get': 'retrieve'}), name='entry-featured'), @@ -75,16 +75,16 @@ AuthorViewSet.as_view({'get': 'retrieve_related'}), name='author-related'), - url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^entries/(?P[^/.]+)/relationships/(?P\w+)$', EntryRelationshipView.as_view(), name='entry-relationships'), - url(r'^blogs/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^blogs/(?P[^/.]+)/relationships/(?P\w+)$', BlogRelationshipView.as_view(), name='blog-relationships'), - url(r'^comments/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^comments/(?P[^/.]+)/relationships/(?P\w+)$', CommentRelationshipView.as_view(), name='comment-relationships'), - url(r'^authors/(?P[^/.]+)/relationships/(?P\w+)', + url(r'^authors/(?P[^/.]+)/relationships/(?P\w+)$', AuthorRelationshipView.as_view(), name='author-relationships'), ] From b52e09e3ff69fe2fefcdd105fadfc53a554d2529 Mon Sep 17 00:00:00 2001 From: Oliver Sauder Date: Sat, 31 Aug 2019 20:16:44 +0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53c21753..3b658b20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,6 @@ This release is not backwards compatible. For easy migration best upgrade first `JSON_API_PLURALIZE_RELATION_TYPE` * Removed obsolete util methods `format_keys` and `format_relation_name` * Removed obsolete pagination classes `PageNumberPagination` and `LimitOffsetPagination` -* Added `$` anchor to example urls to use the best practice of having a full URL match. ### Fixed