Return a ``transform`` for ``_walk_pages`` that prefixes pages under `` /`` with `` /`` and leaves everything else (e.g. ``index``, already-prefixed paths) alone. ``slug_prefix`` is the URL-visible segment: ``v1.14.7`` for a frozen snapshot, ``edge`` for the rolli
(locale: str, slug_prefix: str)
| 79 | |
| 80 | |
| 81 | def _make_prefixer(locale: str, slug_prefix: str): |
| 82 | """Return a ``transform`` for ``_walk_pages`` that prefixes pages under |
| 83 | ``<locale>/`` with ``<slug_prefix>/`` and leaves everything else (e.g. |
| 84 | ``index``, already-prefixed paths) alone. |
| 85 | |
| 86 | ``slug_prefix`` is the URL-visible segment: ``v1.14.7`` for a frozen |
| 87 | snapshot, ``edge`` for the rolling channel. |
| 88 | """ |
| 89 | locale_prefix = f"{locale}/" |
| 90 | prefix_with_slash = f"{slug_prefix}/" |
| 91 | |
| 92 | def transform(page: str) -> str: |
| 93 | if page.startswith(prefix_with_slash): |
| 94 | return page |
| 95 | if page.startswith(locale_prefix): |
| 96 | return f"{prefix_with_slash}{page}" |
| 97 | return page |
| 98 | |
| 99 | return transform |
| 100 | |
| 101 | |
| 102 | def _prefix_version_entry(entry: dict, locale: str) -> dict: |
no outgoing calls
no test coverage detected