Skip to main content

detect_url_scheme

Function
This function is defined in the parse_utils module.
Detect URL scheme from a string. O(1) operation.

Signature

def detect_url_scheme(value: str) -> Optional[str]

Parameters

value
str
required
String to check for URL scheme

Returns

Returns
Optional[str]
Scheme name (lowercase) if URL detected, None otherwise

Usage

>>> detect_url_scheme("postgresql://localhost/db")
    'postgresql'
    >>> detect_url_scheme("redis://localhost:6379")
    'redis'
    >>> detect_url_scheme("not a url")
    None