mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
path_with_added_args now works with multiple existing args
This commit is contained in:
parent
f36c9d4b4c
commit
8a4ed052a5
2 changed files with 5 additions and 2 deletions
|
|
@ -149,10 +149,10 @@ def path_with_added_args(request, args, path=None):
|
||||||
path = path or request.path
|
path = path or request.path
|
||||||
if isinstance(args, dict):
|
if isinstance(args, dict):
|
||||||
args = args.items()
|
args = args.items()
|
||||||
arg_keys = set(a[0] for a in args)
|
args_to_remove = {k for k, v in args if v is None}
|
||||||
current = []
|
current = []
|
||||||
for key, value in urllib.parse.parse_qsl(request.query_string):
|
for key, value in urllib.parse.parse_qsl(request.query_string):
|
||||||
if key not in arg_keys:
|
if key not in args_to_remove:
|
||||||
current.append((key, value))
|
current.append((key, value))
|
||||||
current.extend([
|
current.extend([
|
||||||
(key, value)
|
(key, value)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ def test_urlsafe_components(path, expected):
|
||||||
('/?_facet=state&_facet=city&state=MI', (
|
('/?_facet=state&_facet=city&state=MI', (
|
||||||
('city', 'Detroit'),
|
('city', 'Detroit'),
|
||||||
), '/?_facet=state&_facet=city&state=MI&city=Detroit'),
|
), '/?_facet=state&_facet=city&state=MI&city=Detroit'),
|
||||||
|
('/?_facet=state&_facet=city', (
|
||||||
|
('_facet', 'planet_id'),
|
||||||
|
), '/?_facet=state&_facet=city&_facet=planet_id'),
|
||||||
])
|
])
|
||||||
def test_path_with_added_args(path, added_args, expected):
|
def test_path_with_added_args(path, added_args, expected):
|
||||||
request = Request(
|
request = Request(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue