Skip to content

Commit

Permalink
fix: Ensure upload URLs with trailing slashes working as well
Browse files Browse the repository at this point in the history
  • Loading branch information
playpauseandstop committed Mar 18, 2020
1 parent 67b2b26 commit 08bf527
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
ChangeLog
=========

1.0.0b2 (In Development)
========================

- Ensure trailing slash upload URLs working as well

1.0.0b1 (2020-03-18)
====================

Expand Down
2 changes: 1 addition & 1 deletion aiohttp_tus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ("setup_tus",)
__license__ = "BSD-3-Clause"
__version__ = "1.0.0b1"
__version__ = "1.0.0b2"
5 changes: 4 additions & 1 deletion aiohttp_tus/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import shutil
import uuid
from contextlib import suppress
from pathlib import Path
from typing import Awaitable, Callable, Optional, Tuple

Expand Down Expand Up @@ -164,7 +165,9 @@ def get_config(request: web.Request) -> Config:
config_key = get_upload_url(config_key)

try:
return container[config_key] # type: ignore
with suppress(KeyError):
return container[config_key] # type: ignore
return container[f"{config_key}/"] # type: ignore
except KeyError:
raise KeyError("Unable to find aiohttp_tus config for specified URL")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ show_missing = true

[tool.poetry]
name = "aiohttp-tus"
version = "1.0.0b1"
version = "1.0.0b2"
description = "tus.io protocol implementation for aiohttp.web applications"
authors = ["Igor Davydenko <[email protected]>"]
license = "BSD-3-Clause"
Expand Down
22 changes: 22 additions & 0 deletions tests/test_tus.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,49 @@ async def test_overwrite_file_disallowed(aiohttp_test_client, loop):
"upload_url, canonical_upload_url, upload_suffix, tus_upload_url, match_info",
(
(TEST_UPLOAD_URL, TEST_UPLOAD_URL, None, TEST_UPLOAD_URL, {}),
(f"{TEST_UPLOAD_URL}/", f"{TEST_UPLOAD_URL}/", None, f"{TEST_UPLOAD_URL}/", {}),
(
r"/user/{username}/uploads",
r"/user/{username}/uploads",
None,
"/user/playpauseanddtop/uploads",
{},
),
(
r"/user/{username}/uploads/",
r"/user/{username}/uploads/",
None,
"/user/playpauseanddtop/uploads/",
{},
),
(
r"/user/{username:([a-zA-Z0-9_-])+}/uploads",
r"/user/{username}/uploads",
None,
"/user/playpauseanddtop/uploads",
{},
),
(
r"/user/{username:([a-zA-Z0-9_-])+}/uploads/",
r"/user/{username}/uploads/",
None,
"/user/playpauseanddtop/uploads/",
{},
),
(
r"/user/{username}/uploads",
r"/user/{username}/uploads",
r"{username}",
"/user/playpauseandstop/uploads",
{"username": "playpauseandstop"},
),
(
r"/user/{username}/uploads/",
r"/user/{username}/uploads/",
r"{username}",
"/user/playpauseandstop/uploads/",
{"username": "playpauseandstop"},
),
),
)
async def test_upload(
Expand Down

0 comments on commit 08bf527

Please sign in to comment.