ability to choose if query should (not) be urlencoded
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Bruder 2019-06-13 13:04:52 +00:00
parent 11c515586d
commit 5ceffc07ce
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
3 changed files with 7 additions and 5 deletions

View file

@ -8,9 +8,9 @@ yt: https://www.youtube.com/results?search_query=%s
vimeo: https://vimeo.com/search?q=%s
# Dictionaries
jisho: https://jisho.org/search/%s
jisho: https://jisho.org/search/%S
lide: https://de.linguee.com/deutsch-englisch/search?query=%s
duden: https://www.duden.de/suchen/dudenonline/%s
duden: https://www.duden.de/suchen/dudenonline/%S
# Package search
alpine: https://pkgs.alpinelinux.org/packages?name=%s&arch=x86_64
@ -34,7 +34,7 @@ ebay: https://www.ebay.com/sch/i.html?_nkw=%s
ebayde: https://www.ebay.de/sch/i.html?_nkw=%s
# Archive.org
wayback: https://web.archive.org/web/*/%s
wayback: https://web.archive.org/web/*/%S
# Music
bc: https://bandcamp.com/search?q=%s

View file

@ -46,7 +46,9 @@ func loadBangs() (bangs map[string]string) {
}
func buildSearchURL(template string, query string) (searchUrl string) {
return strings.Replace(template, "%s", url.QueryEscape(query), 1)
searchUrl = strings.Replace(template, "%s", url.QueryEscape(query), 1)
searchUrl = strings.Replace(template, "%S", query, 1)
return
}
func parseBang(searchQuery string) (bang string, query string) {

View file

@ -32,7 +32,7 @@ fetch('https://s3.sbruder.de/cdn/bangs/bangs.json')
}
if (parsedBang !== null) {
redirectURL = bangs[parsedBang.bang].replace('%s', parsedBang.query)
redirectURL = bangs[parsedBang.bang].replace('%s', encodeURI(parsedBang.query)).replace('%S', parsedBang.query)
window.location.replace(redirectURL);
}
})