1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-06 21:14:11 +01:00

Filter out duplicate search strings from search keyword term history completion.

This commit is contained in:
Kris Maglione
2015-01-07 17:10:03 -08:00
parent 4a8affde65
commit 147be2614c

View File

@@ -695,13 +695,15 @@ var Bookmarks = Module("bookmarks", {
context.generate = function () { context.generate = function () {
let [begin, end] = item.url.split("%s"); let [begin, end] = item.url.split("%s");
let seen = RealSet();
return history.get({ uri: util.newURI(begin), uriIsPrefix: true }).map(function (item) { return history.get({ uri: util.newURI(begin), uriIsPrefix: true }).map(function (item) {
let rest = item.url.length - end.length; let rest = item.url.length - end.length;
let query = item.url.substring(begin.length, rest); let query = item.url.substring(begin.length, rest);
if (item.url.substr(rest) == end && query.contains("&")) if (item.url.substr(rest) == end && query.contains("&"))
try { try {
item.url = decodeURIComponent(query.replace(/[&#].*/, "").replace(/\+/g, " ")); item.url = decodeURIComponent(query.replace(/[&#].*/, "").replace(/\+/g, " "));
return item; if (!seen.add(item.url))
return item;
} }
catch (e) {} catch (e) {}
return null; return null;