diff --git a/js/crsearch/crsearch.js b/js/crsearch/crsearch.js index dc3f039..0292aae 100644 --- a/js/crsearch/crsearch.js +++ b/js/crsearch/crsearch.js @@ -6,7 +6,7 @@ import {IndexType as IType} from './index-type' import {Database} from './database' import {Index} from './index' -import {URL} from 'whatwg-url' +import URL from 'url-parse' class CRSearch { @@ -129,16 +129,20 @@ class CRSearch { } database(base_url) { + const autoSuffix = (url) => { + if (url.pathname === '/') url.pathname = '/crsearch.json' + return url + } + try { const url = new URL(base_url) - this.pendingDB.add(url.toString()) + this.pendingDB.add(autoSuffix(url).toString()) } catch (e) { const a = document.createElement('a') a.href = base_url - if (a.pathname == '/') a.pathname = '/crsearch.json' - const url = new URL(a.toString()) + const url = new URL(autoSuffix(a).toString()) this.pendingDB.add(url) } } @@ -276,7 +280,7 @@ class CRSearch { make_google_url(q, site) { let url = this.opts.google_url - url.searchParams.set('q', `${q} site:${site}`) + url.set('query', {q: `${q} site:${site}`}) return url } diff --git a/js/crsearch/database.js b/js/crsearch/database.js index 54b9a05..271607c 100644 --- a/js/crsearch/database.js +++ b/js/crsearch/database.js @@ -5,7 +5,7 @@ import {Namespace} from './namespace' import {Dictionary} from './dictionary' import {Priority, SiteCategory} from './kunai-config' -import {URL} from 'whatwg-url' +import URL from 'url-parse' import * as Query from './query' diff --git a/package-lock.json b/package-lock.json index 007ee77..d1bdf65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4782,11 +4782,6 @@ "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=", "dev": true }, - "lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=" - }, "lodash.tail": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.tail/-/lodash.tail-4.1.1.tgz", @@ -9108,8 +9103,7 @@ "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" }, "resolve": { "version": "1.4.0", @@ -10116,21 +10110,6 @@ "punycode": "1.4.1" } }, - "tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", - "requires": { - "punycode": "2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", - "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=" - } - } - }, "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", @@ -10265,7 +10244,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.2.0.tgz", "integrity": "sha512-DT1XbYAfmQP65M/mE6OALxmXzZ/z1+e5zk2TcSKe/KiYbNGZxgtttzC0mR/sjopbpOXcbniq7eIKmocJnUWlEw==", - "dev": true, "requires": { "querystringify": "1.0.0", "requires-port": "1.0.0" @@ -10274,8 +10252,7 @@ "querystringify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-1.0.0.tgz", - "integrity": "sha1-YoYkIRLFtxL6ZU5SZlK/ahP/Bcs=", - "dev": true + "integrity": "sha1-YoYkIRLFtxL6ZU5SZlK/ahP/Bcs=" } } }, @@ -10382,11 +10359,6 @@ "minimalistic-assert": "1.0.0" } }, - "webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" - }, "webpack": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.8.1.tgz", @@ -10710,16 +10682,6 @@ "integrity": "sha1-Dhh4HeYpoYMIzhSBZQ9n/6JpOl0=", "dev": true }, - "whatwg-url": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.3.0.tgz", - "integrity": "sha512-rM+hE5iYKGPAOu05mIdJR47pYSR2vDzfrTEFRc/S8D3L60yW8BuXmUJ7Kog7x/DrokFN7JNaHKadpzjouKRRAw==", - "requires": { - "lodash.sortby": "4.7.0", - "tr46": "1.0.1", - "webidl-conversions": "4.0.2" - } - }, "whet.extend": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/whet.extend/-/whet.extend-0.9.9.tgz", diff --git a/package.json b/package.json index de25dc5..78c0bc8 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,6 @@ "jquery": "^3.2.1", "marked": "^0.3.6", "nagato": "^1.8.2", - "whatwg-url": "^6.3.0" + "url-parse": "^1.2.0" } }