mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 12:20:07 +00:00
simplify _p9k_url_escape
This commit is contained in:
parent
1cff22491b
commit
fb1287fedb
1 changed files with 3 additions and 10 deletions
|
@ -1747,16 +1747,9 @@ function _p9k_shorten_delim_len() {
|
||||||
# Percents are duplicated because this function is currently used only
|
# Percents are duplicated because this function is currently used only
|
||||||
# where the result is going to be percent-expanded.
|
# where the result is going to be percent-expanded.
|
||||||
function _p9k_url_escape() {
|
function _p9k_url_escape() {
|
||||||
if [[ $1 == [a-zA-Z0-9"/:_.-!'()~ "]# ]]; then
|
emulate -L zsh -o no_multi_byte -o extended_glob
|
||||||
_p9k__ret=${1// /%%20}
|
local MATCH MBEGIN MEND
|
||||||
else
|
_p9k__ret=${1//(#m)[^a-zA-Z0-9"\/:_.-!'()~"]/%%${(l:2::0:)$(([##16]#MATCH))}}
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
Loading…
Reference in a new issue