Skip to content

Commit

Permalink
fix: trailing slash conflict for api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
justEhmadSaeed committed Mar 11, 2024
1 parent 3978df4 commit 4d483ee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion license_manager/apps/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
All API URLs should be versioned, so urlpatterns should only
contain namespaces for the active versions of the API.
"""
import re

from django.urls import include, path

from license_manager.apps.api.v1 import urls as v1_urls


def optional_trailing_slash(urls):
for url in urls[0].urlpatterns:
url.pattern.regex = re.compile(url.pattern.regex.pattern.replace('/$', '/?$'))
return urls


app_name = 'api'
urlpatterns = [
path('v1/', include(v1_urls)),
path('v1/', optional_trailing_slash(include(v1_urls))),
]

0 comments on commit 4d483ee

Please sign in to comment.