Skip to content

Commit

Permalink
Use url-parse instead of whatwg-url
Browse files Browse the repository at this point in the history
  • Loading branch information
saki7 committed Nov 11, 2017
1 parent 14d00e9 commit 933a306
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
14 changes: 9 additions & 5 deletions js/crsearch/crsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion js/crsearch/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
42 changes: 2 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

3 comments on commit 933a306

@yumetodo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saki7
cpprefjp/site#476 (comment)
の件、解決しました

@yumetodo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saki7
Copy link
Contributor Author

@saki7 saki7 commented on 933a306 Nov 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂😂😂😂

Please sign in to comment.