URLs¶
Canonicalize a URL¶
Canonicalization turns a relative URL into a complete URL.
To canonicalize a URL, use this function:
This function returns a URL with a protocol, host, and path.
The domain of the resource is needed so that it can be added to the URL during canonicalization if the URL is relative.
A complete URL returned by this function looks like this:
https://indieweb.org/POSSE
Remove tracking parameters from a URL¶
The remove_tracking_params() function removes tracking parameters from a URL.
This function removes all utm_* parameters from a URL by default. You can specify your own parameters or starts of parameters to remove by passing in a list of strings to the custom_params argument.
Check if a URL is of a given domain¶
The is_site_url() function checks if a URL is of a given domain.
Reduce characters in a URL slug¶
The slugify() function takes a URL and removes all characters that are not:
Alphanumeric characters
Periods
Dashes
Underscores
You can override the default list of characters to remove by passing in a list of strings to the allowed_chars argument (This argument still enforces the alphanumeric requirement).