| 15 | } |
| 16 | |
| 17 | getUrl(queryTerms) { |
| 18 | // This tests whether @searchUrl contains something of the form "...=abc+def+%s...", from which |
| 19 | // we extract a prefix of the form "abc def ". |
| 20 | if (/\=.+\+%s/.test(this.searchUrl)) { |
| 21 | let terms = this.searchUrl.replace(/\+%s.*/, ""); |
| 22 | terms = terms.replace(/.*=/, ""); |
| 23 | terms = terms.replace(/\+/g, " "); |
| 24 | |
| 25 | queryTerms = [...terms.split(" "), ...queryTerms]; |
| 26 | const prefix = `${terms} `; |
| 27 | |
| 28 | this.transformSuggestionsFn = (suggestions) => { |
| 29 | return suggestions |
| 30 | .filter((s) => s.startsWith(prefix)) |
| 31 | .map((s) => s.slice(prefix.length)); |
| 32 | }; |
| 33 | } |
| 34 | |
| 35 | return this.engine.getUrl(queryTerms); |
| 36 | } |
| 37 | |
| 38 | parse(responseText) { |
| 39 | const suggestions = this.engine.parse(responseText); |