use_url_components

use_url_components is a hook that returns the current URL split into components using urllib.parse.urlsplit.

Example

Recommendations

  1. Prefer more specific hooks over use_url_components when possible: use_path for the path, use_query_params for query strings, and use_params for route parameters.
  2. The returned object is a standard Python SplitResult from urllib.parse, so all SplitResult attributes 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 "#")