use_url_components
use_url_components is a hook that returns the current URL split into components using urllib.parse.urlsplit.
Example
Recommendations
- Prefer more specific hooks over
use_url_componentswhen possible:use_pathfor the path,use_query_paramsfor query strings, anduse_paramsfor route parameters. - The returned object is a standard Python
SplitResultfromurllib.parse, so allSplitResultattributes and methods are available.
API Reference
Get the current URL broken into components.
Returns: A SplitResult named tuple with fields scheme: URL scheme (e.g. "https")
netloc: Network location (e.g. "example.com:8080")
path: Path component
query: Query string (without leading "?")
fragment: Fragment (without leading "#")