diff options
| author | Carlo Sala <carlosalag@protonmail.com> | 2024-01-24 10:10:55 +0100 |
|---|---|---|
| committer | Carlo Sala <carlosalag@protonmail.com> | 2024-01-24 10:10:55 +0100 |
| commit | e656377d36077b0ca757d995c9c35f0fea7c7fdd (patch) | |
| tree | 388c99a945d9a10830aff1ffee34d560c00da25e /plugins | |
| parent | f7b647e1b13ed9cd2f34f3559c112e61b8c03108 (diff) | |
| download | zsh-e656377d36077b0ca757d995c9c35f0fea7c7fdd.tar.gz zsh-e656377d36077b0ca757d995c9c35f0fea7c7fdd.tar.bz2 zsh-e656377d36077b0ca757d995c9c35f0fea7c7fdd.zip | |
fix(web-search): encode spaces as `%20`
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/web-search/web-search.plugin.zsh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 1b42abe86..0fa2852dc 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -37,9 +37,14 @@ function web_search() { # search or go to main page depending on number of arguments passed 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: # 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 # build main page url: # split by '/', then rejoin protocol (1) and domain (2) parts with '//' |
