Skip to content

Commit 0c94bae

Browse files
authored
Allow first path segments containing colons (#192)
* Allow first path segments containing colons * Remove unused type ignore
1 parent 3981b5b commit 0c94bae

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

respx/patterns.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ def parse(self, request: httpx.Request) -> str:
388388
return request.url.path
389389

390390
def strip_base(self, value: str) -> str:
391-
value = urljoin("/", value[len(self.base.value) :])
391+
value = value[len(self.base.value) :]
392+
value = "/" + value if not value.startswith("/") else value
392393
return value
393394

394395

respx/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ async def aresolve(self, request: httpx.Request) -> ResolvedRoute:
296296
# Await async side effect and wrap any exception
297297
if inspect.isawaitable(prospect):
298298
try:
299-
prospect = await prospect # type: ignore
299+
prospect = await prospect
300300
except Exception as error:
301301
raise SideEffectError(route, origin=error) from error
302302

tests/test_router.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def test_pass_through():
9595
("http://foo.bar/api/baz/", {"url": "/baz/"}, False),
9696
("https://ham.spam/api/baz/", {"url": "/baz/"}, False),
9797
("https://foo.bar/baz/", {"url": "/baz/"}, False),
98+
("https://foo.bar/api/hej:svejs", {"url": "/hej:svejs"}, True),
9899
],
99100
)
100101
def test_base_url(url, lookups, expected):

0 commit comments

Comments
 (0)