Functions
normalize_url
Normalize a relative URL to a consistent format.
Rules:
- Always starts with /
- No multiple conse…
normalize_url
def normalize_url(url: str, ensure_trailing_slash: bool = True) -> str
Normalize a relative URL to a consistent format.
Rules:
- Always starts with /
- No multiple consecutive slashes (except after protocol)
- Trailing slash for directory-like URLs (if ensure_trailing_slash=True)
- Root is "/"
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
url |
str |
— | URL to normalize (can be empty, relative, or absolute) |
ensure_trailing_slash |
bool |
True |
Whether to ensure trailing slash (default: True) |
Returns
Normalized URL stringstr
—
join_url_paths
Join URL path components, normalizing slashes.
join_url_paths
def join_url_paths(*parts: str) -> str
Join URL path components, normalizing slashes.
Returns
Normalized joined URLstr
—
validate_url
Validate that a URL is in correct format.
validate_url
def validate_url(url: str) -> bool
Validate that a URL is in correct format.
Parameters 1
| Name | Type | Default | Description |
|---|---|---|---|
url |
str |
— | URL to validate |
Returns
True if URL is valid, False otherwisebool
—