mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Address PrefixedUrlString bug in #1075
This commit is contained in:
parent
bf18b9ba17
commit
a4ca26a265
6 changed files with 16 additions and 2 deletions
|
|
@ -822,6 +822,9 @@ class Datasette:
|
|||
if url in seen_urls:
|
||||
continue
|
||||
seen_urls.add(url)
|
||||
if url.startswith("/"):
|
||||
# Take base_url into account:
|
||||
url = self.urls.path(url)
|
||||
if sri:
|
||||
output.append({"url": url, "sri": sri})
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import asyncio
|
||||
from contextlib import contextmanager
|
||||
import click
|
||||
from collections import OrderedDict, namedtuple
|
||||
import base64
|
||||
import click
|
||||
import hashlib
|
||||
import inspect
|
||||
import itertools
|
||||
|
|
@ -1016,8 +1016,11 @@ class PrefixedUrlString(str):
|
|||
def __add__(self, other):
|
||||
return type(self)(super().__add__(other))
|
||||
|
||||
def __str__(self):
|
||||
return super().__str__()
|
||||
|
||||
def __getattribute__(self, name):
|
||||
if name in dir(str):
|
||||
if not name.startswith("__") and name in dir(str):
|
||||
|
||||
def method(self, *args, **kwargs):
|
||||
value = getattr(super(), name)(*args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ METADATA = {
|
|||
"source_url": "https://github.com/simonw/datasette/blob/master/tests/fixtures.py",
|
||||
"about": "About Datasette",
|
||||
"about_url": "https://github.com/simonw/datasette",
|
||||
"extra_css_urls": ["/static/extra-css-urls.css"],
|
||||
"plugins": {
|
||||
"name-of-plugin": {"depth": "root"},
|
||||
"env-plugin": {"foo": {"$env": "FOO_ENV"}},
|
||||
|
|
|
|||
|
|
@ -1852,6 +1852,7 @@ def test_paginate_using_link_header(app_client, qs):
|
|||
num_pages = 0
|
||||
while path:
|
||||
response = app_client.get(path)
|
||||
assert response.status == 200
|
||||
num_pages += 1
|
||||
link = response.headers.get("link")
|
||||
if link:
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ def test_serve_with_get_exit_code_for_error(tmp_path_factory):
|
|||
"--get",
|
||||
"/this-is-404",
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert "404" in result.output
|
||||
|
|
|
|||
|
|
@ -1466,6 +1466,11 @@ def test_base_url_config(app_client_base_url_prefix, path):
|
|||
}
|
||||
|
||||
|
||||
def test_base_url_affects_metadata_extra_css_urls(app_client_base_url_prefix):
|
||||
html = app_client_base_url_prefix.get("/").text
|
||||
assert '<link rel="stylesheet" href="/prefix/static/extra-css-urls.css">' in html
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue