From 5ceffc07ce12e26b3419340cc20579a04a6fbe44 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 13 Jun 2019 13:04:52 +0000 Subject: [PATCH] ability to choose if query should (not) be urlencoded --- bangs.yml | 6 +++--- evaluator/evaluator.go | 4 +++- startpage.user.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bangs.yml b/bangs.yml index 1fb3b25..9761114 100644 --- a/bangs.yml +++ b/bangs.yml @@ -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 diff --git a/evaluator/evaluator.go b/evaluator/evaluator.go index 6dc5b56..03234b3 100644 --- a/evaluator/evaluator.go +++ b/evaluator/evaluator.go @@ -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) { diff --git a/startpage.user.js b/startpage.user.js index 530edc0..247694b 100644 --- a/startpage.user.js +++ b/startpage.user.js @@ -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); } })