Address PrefixedUrlString bug in #1075

This commit is contained in:
Simon Willison 2020-10-31 13:35:47 -07:00
commit a4ca26a265
6 changed files with 16 additions and 2 deletions

View file

@ -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:

View file

@ -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)