Skip to content

Commit

Permalink
Merge branch 'master' into simplify-inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhsf authored Feb 2, 2024
2 parents d4f3c2d + 24ecc86 commit 25d108c
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 117 deletions.
4 changes: 2 additions & 2 deletions lib/cookie/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// This file was too big before we added max-lines, and it's ongoing work to reduce its size.
/* eslint max-lines: [1, 750] */

import * as pubsuffix from '../pubsuffix-psl'
import { getPublicSuffix } from '../getPublicSuffix'
import * as validators from '../validators'
import { inOperator, NODEJS_UTIL_INSPECT_CUSTOM } from '../utils'

Expand Down Expand Up @@ -554,7 +554,7 @@ export class Cookie {
if (cdomain.match(/\.$/)) {
return false // S4.1.2.3 suggests that this is bad. domainMatch() tests confirm this
}
const suffix = pubsuffix.getPublicSuffix(cdomain)
const suffix = getPublicSuffix(cdomain)
if (suffix == null) {
// it's a public suffix
return false
Expand Down
4 changes: 2 additions & 2 deletions lib/cookie/cookieJar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import urlParse from 'url-parse'

import * as pubsuffix from '../pubsuffix-psl'
import { getPublicSuffix } from '../getPublicSuffix'
import * as validators from '../validators'
import { Store } from '../store'
import { MemoryCookieStore } from '../memstore'
Expand Down Expand Up @@ -303,7 +303,7 @@ export class CookieJar {
const cdomain = cookie.cdomain()
const suffix =
typeof cdomain === 'string'
? pubsuffix.getPublicSuffix(cdomain, {
? getPublicSuffix(cdomain, {
allowSpecialUseDomain: this.allowSpecialUseDomain,
ignoreError: options?.ignoreError,
})
Expand Down
3 changes: 2 additions & 1 deletion lib/cookie/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { MemoryCookieStore } from '../memstore'
export { pathMatch } from '../pathMatch'
export { permuteDomain } from '../permuteDomain'
export { getPublicSuffix } from '../pubsuffix-psl'
export { getPublicSuffix } from '../getPublicSuffix'
export { Store } from '../store'
export { ParameterError } from '../validators'
export { version } from '../version'
Expand All @@ -18,4 +18,5 @@ export { parseDate } from './parseDate'
export { permutePath } from './permutePath'

import { Cookie } from './cookie'

export const fromJSON = Cookie.fromJSON
7 changes: 5 additions & 2 deletions lib/pubsuffix-psl.ts → lib/getPublicSuffix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
'use strict'
import * as psl from 'psl'
import { getDomain } from 'tldts'

// RFC 6761
const SPECIAL_USE_DOMAINS = ['local', 'example', 'invalid', 'localhost', 'test']
Expand Down Expand Up @@ -84,5 +84,8 @@ export function getPublicSuffix(
)
}

return psl.get(domain)
return getDomain(domain, {
allowIcannDomains: true,
allowPrivateDomains: true,
})
}
2 changes: 1 addition & 1 deletion lib/permuteDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
'use strict'
import { getPublicSuffix } from './pubsuffix-psl'
import { getPublicSuffix } from './getPublicSuffix'

// Gives the permutation of all possible domainMatch()es of a given domain. The
// array is in shortest-to-longest order. Handy for indexing.
Expand Down
Loading

0 comments on commit 25d108c

Please sign in to comment.