Fix shit done on omz_urlencode rework by someone

Bad usage of zparseopts
This commit is contained in:
Gaetan Semet 2015-10-17 18:03:44 +02:00
commit 279d67d702

View file

@ -120,12 +120,15 @@ zmodload zsh/langinfo
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
zparseopts -D -E -a opts r m P
local -a opt_path opt_reserved opt_mark
zparseopts -D -E r=opt_reserved m=opt_mark P=opt_path
local in_str=$1
local url_str=""
local spaces_as_plus
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
local spaces_as_plus=1
if [[ ! -z $opt_path ]]; then
spaces_as_plus=
fi
local str="$in_str"
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
@ -146,11 +149,11 @@ function omz_urlencode() {
local reserved=';/?:@&=+$,'
local mark='_.!~*''()-'
local dont_escape="[A-Za-z0-9"
if [[ -z $opts[(r)-r] ]]; then
if [[ ! -z $opt_reserved ]]; then
dont_escape+=$reserved
fi
# $mark must be last because of the "-"
if [[ -z $opts[(r)-m] ]]; then
if [[ ! -z $opt_mark ]]; then
dont_escape+=$mark
fi
dont_escape+="]"