python-url-normalize
Port variant v15
Summary URL normalization for Python (3.15)
Package version 4.0.0
Homepage https://github.com/niksite/url-normalize
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v14
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 23 NOV 2026, 05:55:02 UTC
Port created 25 APR 2024, 22:29:23 UTC
Subpackage Descriptions
single # url-normalize [tests] [Coveralls] [PyPI] [Python Versions] [License] [Ruff] Normalize URL spelling consistently for storage, comparison, and display. Use `url_normalize()` for normalized URLs and `url_humanize()` for readable display URLs. Requires **Python 3.11 or newer**. Normalization operates on URL text; it does not fetch pages or follow redirects. ## Installation These examples use url-normalize 4.0.0. If you store normalized URLs or use custom parameter filters, read the [4.0.0 upgrade notes] before upgrading. The [3.1.0 usage guide] covers the previous release. Install the library and CLI: ```sh python -m pip install "url-normalize>=4.0.0" ``` Or install the CLI in its own environment with [uv]: ```sh uv tool install "url-normalize>=4.0.0" ``` ## Quick start ```python from url_normalize import url_normalize print(url_normalize("HTTP://Example.COM:80/a/../b")) # Output: http://example.com/b print(url_normalize("bücher.de/résumé")) # Output: https://xn--bcher-kva.de/r%C3%A9sum%C3%A9 ``` From the terminal: ```sh url-normalize "HTTP://Example.COM:80/a/../b" # Output: http://example.com/b ``` ## Normalization behavior | Behavior | Input | Output | | --- | --- | --- | | Add a missing scheme | `example.com` | `https://example.com/` | | Lowercase scheme and host; remove a default port | `HTTP://Example.COM:80/` | `http://example.com/` | | Resolve dot segments | `https://example.com/a/../b` | `https://example.com/b` | | Collapse repeated path slashes | `https://example.com/a//b///` | `https://example.com/a/b/` | | Encode Unicode hosts and paths | `https://bücher.de/résumé` | `https://xn--bcher-kva.de/r%C3%A9sum%C3%A9` | | Remove one trailing host dot, including Unicode equivalents | `https://example.com。/` | `https://example.com/` | | Preserve encoded path separators; uppercase escape hex | `https://example.com/a%2fb` | `https://example.com/a%2Fb` | | Preserve query order and repeated keys | `https://example.com/?b=2&a=1&a=3` | `https://example.com/?b=2&a=1&a=3` | | Preserve explicit empty query values | `https://example.com/?flag=&flag` | `https://example.com/?flag=&flag` | | Remove empty query and fragment components | `https://example.com/?#` | `https://example.com/` | | Preserve an explicit relative reference | `../images/a.png` | `../images/a.png` | | Preserve fragment routes | `https://example.com/#!/users/42` | `https://example.com/#!/users/42` | | Preserve text-highlight syntax | `https://example.com/#:~:text=hello%20world` | `https://example.com/#:~:text=hello%20world` | In query parameters, `+`, `%2B`, and `%20` remain distinct. Parameter filtering is disabled by default. Fragments are preserved and normalized by default, including hashbang routes (`#!/route`) and text directives (`#:~:text=hello`). Use `strip_fragment=True` to remove the entire fragment explicitly. Fragments keep literal RFC 3986 fragment punctuation and existing ASCII escapes, with uppercase escape hex. This deliberately includes escaped letters, hyphens and tildes: fragment syntax can be interpreted before percent-decoding. For example, `#:%7E:text=hello` stays encoded instead of becoming an active text directive. Unicode text uses UTF-8 and NFC normalization as usual. Hashbang fragments are no longer converted into `_escaped_fragment_` query parameters. Empty query and fragment delimiters are removed by default. Set `keep_empty_components=True` in either Python API, or use
Configuration Switches (platform-specific settings discarded)
PY314 OFF Build using Python 3.14 PY315 ON Build using Python 3.15
Package Dependencies by Type
Build (only) python315:dev:std
python-pip:single:v15
autoselect-python:single:std
Build and Runtime python315:primary:std
Runtime (only) python-idna:single:v15
Download groups
main mirror://PYPIWHL/90/69/b99d4032fd4a2984e7ec0756ef84c031f3cb7b909c2d3b592aa7b0bb7d57
Distribution File Information
dea616fc9c3d4c8bcd46fcaa783bb4e402b4f272789650919e473c5a86a7b3eb 35372 python-src/url_normalize-4.0.0-py3-none-any.whl
Ports that require python-url-normalize:v15
python-requests-cache:v15 Persistent cache for python requests (3.15)