mdurl

raw JSON →
0.1.2 verified Tue May 12 auth: no python install: verified quickstart: verified

mdurl is a Python port of the JavaScript mdurl package, providing utilities for parsing, encoding, and decoding URLs in Markdown. The latest version is 0.1.2, released on August 14, 2022. The project has a stable release history with no recent updates.

pip install mdurl
error ModuleNotFoundError: No module named 'mdurl'
cause The 'mdurl' package is not installed in the Python environment where the code is being run.
fix
Install the package using pip: pip install mdurl
error AttributeError: module 'mdurl' has no attribute 'quote'
cause The user is attempting to call a function that does not exist in the `mdurl` library, possibly confusing its API with other URL parsing libraries like `urllib.parse` or the original JavaScript `mdurl`.
fix
Refer to the mdurl documentation. The primary encoding function is mdurl.encode() and the decoding function is mdurl.decode().
error TypeError: argument 's' must be str, not int
cause The `mdurl.encode()` or `mdurl.decode()` function received an argument that is not a string, but an integer (or another non-string type) instead.
fix
Ensure that the input provided to mdurl.encode() or mdurl.decode() is a string.
error ValueError: Malformed URL scheme
cause While `mdurl.parse()` is designed to be lenient, if the input URL string is severely malformed, particularly regarding its scheme or structure (e.g., `https:/example.com` instead of `https://example.com`), it can lead to unexpected parsing results or a `ValueError` if subsequent operations on the parsed object assume a valid structure.
fix
Validate and ensure that the URL string passed to mdurl.parse() or other functions has a reasonably well-formed structure, including the correct scheme (e.g., http://, https://).
gotcha mdurl functions do not perform URL normalization; ensure input URLs are properly formatted.
fix Manually normalize URLs before processing if necessary.
gotcha Invalid percent-encoded sequences are left as-is during decoding.
fix Validate URLs before decoding to handle invalid sequences appropriately.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.02s 17.8M
3.10 slim (glibc) - - 0.01s 18M
3.11 alpine (musl) - - 0.04s 19.7M
3.11 slim (glibc) - - 0.03s 20M
3.12 alpine (musl) - - 0.03s 11.6M
3.12 slim (glibc) - - 0.04s 12M
3.13 alpine (musl) - - 0.03s 11.2M
3.13 slim (glibc) - - 0.03s 12M
3.9 alpine (musl) - - 0.02s 17.3M
3.9 slim (glibc) - - 0.01s 18M

Demonstrates encoding, decoding, parsing, and formatting URLs using mdurl.

from mdurl import encode, decode, parse, format

# Encode a URL
encoded_url = encode('https://example.com/path?query=param')
print(f'Encoded URL: {encoded_url}')

# Decode a URL
decoded_url = decode(encoded_url)
print(f'Decoded URL: {decoded_url}')

# Parse a URL
parsed_url = parse('https://example.com/path?query=param')
print(f'Parsed URL: {parsed_url}')

# Format a parsed URL
formatted_url = format(parsed_url)
print(f'Formatted URL: {formatted_url}')