Skip to main content

filepath_to_uri

Convert a file system path to a URI portion that is suitable for inclusion in a URL.

Encode certain chars that would normally be recognized as special chars
for URIs. Do not encode the ' character, as it is a valid character
within URIs. See the encodeURIComponent() JavaScript function for details.
def filepath_to_uri(
path: string
) - > string

Convert a file system path to a URI portion that is suitable for inclusion in a URL. Encode certain chars that would normally be recognized as special chars for URIs. Do not encode the ' character, as it is a valid character within URIs. See the encodeURIComponent() JavaScript function for details.

Parameters

NameTypeDescription
pathstringThe file system path to be converted and encoded for URL compatibility

Returns

TypeDescription
stringThe URI-encoded string with backslashes replaced by forward slashes, or the original value if the input is None