Skip to content

Commit

Permalink
fix urls: multiple instead complex regex
Browse files Browse the repository at this point in the history
  • Loading branch information
DylannCordel committed Jul 12, 2023
1 parent 13d4266 commit b3c409f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
33 changes: 30 additions & 3 deletions dalec/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,40 @@
# Third Party
from dalec.views import FetchContentView

fetch_content_view = FetchContentView.as_view()
urlpatterns = [
re_path(
(
"(?P<app>[a-z][a-z0-9_-]+)/(?P<content_type>[a-z][a-z0-9_-]+)" # required part
"(?:/(?P<channel>[a-zA-Z][a-zA-Z0-9_-]+)(?:/(?P<channel_object>[^/]+)?(?:/(?P<ordered_by>[^/]+)?)))?" # opt part # noqa
"/(?P<channel>[a-zA-Z][a-zA-Z0-9_-]+)"
"/(?P<channel_object>[^/]+)"
"/(?P<ordered_by>[^/]+)"
),
FetchContentView.as_view(),
fetch_content_view,
name="dalec_fetch_content",
)
),
re_path(
(
"(?P<app>[a-z][a-z0-9_-]+)/(?P<content_type>[a-z][a-z0-9_-]+)" # required part
"/(?P<channel>[a-zA-Z][a-zA-Z0-9_-]+)"
"/(?P<channel_object>[^/]+)"
),
fetch_content_view,
name="dalec_fetch_content",
),
re_path(
(
"(?P<app>[a-z][a-z0-9_-]+)/(?P<content_type>[a-z][a-z0-9_-]+)" # required part
"/(?P<channel>[a-zA-Z][a-zA-Z0-9_-]+)"
),
fetch_content_view,
name="dalec_fetch_content",
),
re_path(
(
"(?P<app>[a-z][a-z0-9_-]+)/(?P<content_type>[a-z][a-z0-9_-]+)" # required part
),
fetch_content_view,
name="dalec_fetch_content",
),
]
7 changes: 3 additions & 4 deletions dalec_example/proxy.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Optional, Dict

from datetime import timedelta, datetime
from datetime import datetime, timedelta

import requests

from django.utils.dateparse import parse_datetime
from django.utils.timezone import make_aware
from django.utils.timezone import now
from django.utils.timezone import make_aware, now

from dalec.proxy import Proxy

Expand Down

0 comments on commit b3c409f

Please sign in to comment.