datasette.urls methods will not apply base_url prefix twice, refs #1026

This commit is contained in:
Simon Willison 2020-10-31 12:11:40 -07:00
commit 7a67bc7a56
4 changed files with 70 additions and 17 deletions

View file

@ -443,6 +443,8 @@ These functions can be accessed via the ``{{ urls }}`` object in Datasette templ
Use the ``format="json"`` (or ``"csv"`` or other formats supported by plugins) arguments to get back URLs to the JSON representation. This is usually the path with ``.json`` added on the end, but it may use ``?_format=json`` in cases where the path already includes ``.json``, for example a URL to a table named ``table.json``.
These methods each return a ``datasette.utils.PrefixedUrlString`` object, which is a subclass of the Python ``str`` type. This allows the logic that considers the ``base_url`` setting to detect if that prefix has already been applied to the path.
.. _internals_database:
Database class