Tilde encoding now encodes space as plus, closes #1701

Refs #1657
This commit is contained in:
Simon Willison 2022-04-06 08:55:01 -07:00
commit 90d1be9952
4 changed files with 18 additions and 7 deletions

View file

@ -980,15 +980,17 @@ Datasette uses a custom encoding scheme in some places, called **tilde encoding*
Tilde encoding uses the same algorithm as `URL percent-encoding <https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding>`__, but with the ``~`` tilde character used in place of ``%``.
Any character other than ``ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789_-`` will be replaced by the numeric equivalent preceded by a tilde. For example:
Any character other than ``ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789_-`` will be replaced by the numeric equivalent preceded by a tilde. For example:
- ``/`` becomes ``~2F``
- ``.`` becomes ``~2E``
- ``%`` becomes ``~25``
- ``~`` becomes ``~7E``
- Space character becomes ``~20``
- Space becomes ``+``
- ``polls/2022.primary`` becomes ``polls~2F2022~2Eprimary``
Note that the space character is a special case: it will be replaced with a ``+`` symbol.
.. _internals_utils_tilde_encode:
.. autofunction:: datasette.utils.tilde_encode