kopia lustrzana https://github.com/simonw/datasette
Fix handling of nested custom page wildcard paths, closes #996
rodzic
b37431976c
commit
5070425817
|
@ -1204,7 +1204,7 @@ def route_pattern_from_filepath(filepath):
|
|||
re_bits.append("(?P<{}>[^/]*)".format(bit[1:-1]))
|
||||
else:
|
||||
re_bits.append(re.escape(bit))
|
||||
return re.compile("".join(re_bits))
|
||||
return re.compile("^" + "".join(re_bits) + "$")
|
||||
|
||||
|
||||
class NotFoundExplicit(NotFound):
|
||||
|
|
|
@ -64,10 +64,15 @@ def test_redirect2(custom_pages_client):
|
|||
assert "/example" == response.headers["Location"]
|
||||
|
||||
|
||||
def test_custom_route_pattern(custom_pages_client):
|
||||
response = custom_pages_client.get("/route_Sally")
|
||||
@pytest.mark.parametrize("path,expected", [
|
||||
("/route_Sally", "<p>Hello from Sally</p>"),
|
||||
("/topic_python", "Topic page for python"),
|
||||
("/topic_python/info", "Slug: info, Topic: python"),
|
||||
])
|
||||
def test_custom_route_pattern(custom_pages_client, path, expected):
|
||||
response = custom_pages_client.get(path)
|
||||
assert response.status == 200
|
||||
assert response.text.strip() == "<p>Hello from Sally</p>"
|
||||
assert response.text.strip() == expected
|
||||
|
||||
|
||||
def test_custom_route_pattern_404(custom_pages_client):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Topic page for {{ topic }}
|
|
@ -0,0 +1 @@
|
|||
Slug: {{ slug }}, Topic: {{ topic }}
|
Ładowanie…
Reference in New Issue