1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-15 18:30:08 +00:00

fix(web-search): encode spaces as %20

This commit is contained in:
Carlo Sala 2024-01-24 10:10:55 +01:00
parent f7b647e1b1
commit e656377d36
No known key found for this signature in database
GPG key ID: DA6FB450C1A4FE9A

View file

@ -37,9 +37,14 @@ function web_search() {
# search or go to main page depending on number of arguments passed # search or go to main page depending on number of arguments passed
if [[ $# -gt 1 ]]; then if [[ $# -gt 1 ]]; then
# if search goes in the query string ==> space as +, otherwise %20
# see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
local param="-P"
[[ "$urls[$1]" =~ .*\?.*=$ ]] && param=""
# build search url: # build search url:
# join arguments passed with '+', then append to search engine URL # join arguments passed with '+', then append to search engine URL
url="${urls[$1]}$(omz_urlencode ${@[2,-1]})" url="${urls[$1]}$(omz_urlencode $param ${@[2,-1]})"
else else
# build main page url: # build main page url:
# split by '/', then rejoin protocol (1) and domain (2) parts with '//' # split by '/', then rejoin protocol (1) and domain (2) parts with '//'