aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
Diffstat (limited to 'src/background')
-rw-r--r--src/background/usecases/parsers.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/background/usecases/parsers.js b/src/background/usecases/parsers.js
index 650ccd0..cda26c3 100644
--- a/src/background/usecases/parsers.js
+++ b/src/background/usecases/parsers.js
@@ -1,3 +1,8 @@
+const trimStart = (str) => {
+ // NOTE String.trimStart is available on Firefox 61
+ return str.replace(/^\s+/, '');
+};
+
const normalizeUrl = (keywords, searchSettings) => {
try {
return new URL(keywords).href;
@@ -8,10 +13,10 @@ const normalizeUrl = (keywords, searchSettings) => {
let template = searchSettings.engines[searchSettings.default];
let query = keywords;
- let first = keywords.trimStart().split(' ')[0];
+ let first = trimStart(keywords).split(' ')[0];
if (Object.keys(searchSettings.engines).includes(first)) {
template = searchSettings.engines[first];
- query = keywords.trimStart().slice(first.length).trimStart();
+ query = trimStart(trimStart(keywords).slice(first.length));
}
return template.replace('{}', encodeURIComponent(query));
}