[UPDT] HORILLA CRUMBS: Function to check for valid UUIDs in addition to numeric IDs in request path
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import uuid
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
@@ -8,6 +9,14 @@ from employee.models import Employee
|
|||||||
from horilla.urls import urlpatterns
|
from horilla.urls import urlpatterns
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_uuid(uuid_string):
|
||||||
|
try:
|
||||||
|
uuid.UUID(uuid_string, version=4)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _split_path(self, path=None):
|
def _split_path(self, path=None):
|
||||||
"""Returns a list of the path components between slashes"""
|
"""Returns a list of the path components between slashes"""
|
||||||
if not path:
|
if not path:
|
||||||
@@ -228,7 +237,7 @@ def breadcrumbs(request):
|
|||||||
|
|
||||||
new_dict = {"url": path, "name": item, "found": found}
|
new_dict = {"url": path, "name": item, "found": found}
|
||||||
|
|
||||||
if item.isdigit():
|
if item.isdigit() or is_valid_uuid(item):
|
||||||
# Handle the case when item is a digit (e.g., an ID)
|
# Handle the case when item is a digit (e.g., an ID)
|
||||||
current_url = resolve(request.path_info)
|
current_url = resolve(request.path_info)
|
||||||
url_kwargs = current_url.kwargs
|
url_kwargs = current_url.kwargs
|
||||||
|
|||||||
Reference in New Issue
Block a user