Skip to content

Commit 28c94f0

Browse files
committed
Remove strange function overloading
Removing this behavior caused one test to fail, and the test was sending an array to a function which expected a string. I did some light live testing and didn't notice any breakage.
1 parent fcb2960 commit 28c94f0

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

background_scripts/completion_engines.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class BaseEngine {
4040
return Utils.matchesAnyRegexp(this.regexps, searchUrl);
4141
}
4242
getUrl(queryTerms) {
43-
return UrlUtils.createSearchUrl(queryTerms, this.engineUrl);
43+
return UrlUtils.createSearchUrl(queryTerms.join(" "), this.engineUrl);
4444
}
4545
}
4646

lib/url_utils.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,10 @@ const UrlUtils = {
127127
return searchUrl.replace(/%s/g, this.createSearchQuery(query));
128128
},
129129

130-
// Map a search query to its URL encoded form. The query may be either a string or an array of
131-
// strings. E.g. "BBC Sport" -> "BBC%20Sport".
132-
// TODO(philc): Why do we allow both a string and array as arguments? Let's pick one and change
133-
// the callers.
130+
// Map a search query to its URL encoded form. E.g. "BBC Sport" -> "BBC%20Sport".
134131
createSearchQuery(query) {
135-
if (typeof query === "string") {
136-
query = query.split(/\s+/);
137-
}
138-
return query.map(encodeURIComponent).join("%20");
132+
const parts = query.split(/\s+/);
133+
return parts.map(encodeURIComponent).join("%20");
139134
},
140135
};
141136

0 commit comments

Comments
 (0)