DEV Community

Samandar Ravshanov
Samandar Ravshanov

Posted on

3 3

๐Ÿ“ฆ Convert relative file system paths into safe URI paths

from functorflow import f

# Properly encode URI path segments
r = f('uri-path', '../abc/@#$%ยจ&()[]{}-_=+รŸ/mรดรฒรฑ ๆœˆ ู‚ู…ุฑ')
print(r)
# -> '../abc/%40%23%24%25%C2%A8%26()%5B%5D%7B%7D-_%3D%2B%C3%9F/m%C3%B4%C3%B2%C3%B1%20%E6%9C%88%20%D9%82%D9%85%D8%B1'


# Also supports paths with Windows directory separators
print(f('uri-path', 'a\\b\\c'))
# -> 'a/b/c'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay