diff options
author | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2023-04-07 14:24:49 +0300 |
---|---|---|
committer | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2023-04-07 14:24:49 +0300 |
commit | fb1287fedbb877201572d164ba0bad5c9d375b4f (patch) | |
tree | 180957abf04e0f0c323b0fe642321284d2807a12 /internal/p10k.zsh | |
parent | 1cff22491b730c6a7bed7a306376f975ee16f81f (diff) |
simplify _p9k_url_escape
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r-- | internal/p10k.zsh | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index cd49b689..d638cfc1 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1747,16 +1747,9 @@ function _p9k_shorten_delim_len() { # Percents are duplicated because this function is currently used only # where the result is going to be percent-expanded. function _p9k_url_escape() { - if [[ $1 == [a-zA-Z0-9"/:_.-!'()~ "]# ]]; then - _p9k__ret=${1// /%%20} - else - local c - _p9k__ret= - for c in ${(s::)1}; do - [[ $c == [a-zA-Z0-9"/:_.-!'()~"] ]] || printf -v c '%%%%%02X' $(( #c )) - _p9k__ret+=$c - done - fi + emulate -L zsh -o no_multi_byte -o extended_glob + local MATCH MBEGIN MEND + _p9k__ret=${1//(#m)[^a-zA-Z0-9"\/:_.-!'()~"]/%%${(l:2::0:)$(([##16]#MATCH))}} } ################################################################ |