Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion background_scripts/completion_engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ class Brave extends BaseEngine {
}
}

// Kagi is a paid ad-free search engine
class Kagi extends BaseEngine {
constructor() {
super({
engineUrl: "https://kagi.com/autosuggest?q=%s",
regexps: ["^https?://www\\.kagi\\.com/"],
example: {
searchUrl: "https://www.kagi.com/search?q=%s",
keyword: "k",
},
});
}

parse(text) {
return JSON.parse(text).map((suggestion) => suggestion.t);
}
}

// On the user-facing documentation page pages/completion_engines.html, these completion search
// engines will be shown to the user in this order.
const CompletionEngines = [
Expand All @@ -241,8 +259,9 @@ const CompletionEngines = [
Webster,
Qwant,
Brave,
Kagi,
];

globalThis.CompletionEngines = CompletionEngines;

export { Amazon, Brave, DuckDuckGo, Qwant, Webster };
export { Amazon, Brave, DuckDuckGo, Kagi, Qwant, Webster };
8 changes: 8 additions & 0 deletions tests/unit_tests/completion_engines_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ context("Brave completion", () => {
});
});

context("Kagi completion", () => {
should("parses results", () => {
const response = JSON.stringify([{ t: "one" }, { t: "two" }]);
const results = new Engines.Kagi().parse(response);
assert.equal(["one", "two"], results);
});
});

context("DuckDuckGo completion", () => {
should("parses results", () => {
const response = JSON.stringify([
Expand Down