Last active
November 12, 2019 07:24
-
-
Save cbrunnkvist/7a5e780988cbbef8d28408dc2e730be0 to your computer and use it in GitHub Desktop.
echo $annoyingPath | encodeURI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I actually just pasted this inline as part of a TC buildstep but hey, wanna get the Gist to color coding correctly | |
encodeURI() { | |
# for each char from stdin | |
old_lc_collate=$LC_COLLATE | |
LC_COLLATE=C | |
for c in $(grep -o .) | |
do | |
case $c in | |
[a-zA-Z0-9.~_-/?=&]) printf "$c" ;; | |
*) printf '%%%02X' "'$c" ;; | |
esac | |
done | |
LC_COLLATE=$old_lc_collate | |
echo | |
} | |
encodeURI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment