bare-url 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +5 -3
- package/lib/url-search-params.d.ts +4 -0
- package/lib/url-search-params.js +19 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ declare class URL {
|
|
|
25
25
|
declare namespace URL {
|
|
26
26
|
export function isURL(value: unknown): value is URL
|
|
27
27
|
|
|
28
|
+
export function isURLSearchParams(value: unknown): value is URLSearchParams
|
|
29
|
+
|
|
28
30
|
export function parse(input: string, base?: string | URL): URL | null
|
|
29
31
|
|
|
30
32
|
export function canParse(input: string, base?: string | URL): boolean
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const kind = Symbol.for('bare.url.kind')
|
|
|
7
7
|
|
|
8
8
|
const isWindows = Bare.platform === 'win32'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
class URL {
|
|
11
11
|
static get [kind]() {
|
|
12
12
|
return 0 // Compatibility version
|
|
13
13
|
}
|
|
@@ -256,6 +256,8 @@ module.exports = exports = class URL {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
module.exports = exports = URL
|
|
260
|
+
|
|
259
261
|
// https://url.spec.whatwg.org/#url-opaque-path
|
|
260
262
|
function hasOpaquePath(url) {
|
|
261
263
|
return url.pathname[0] !== '/'
|
|
@@ -266,8 +268,6 @@ function cannotHaveCredentialsOrPort(url) {
|
|
|
266
268
|
return url.hostname === '' || url.protocol === 'file:'
|
|
267
269
|
}
|
|
268
270
|
|
|
269
|
-
const URL = exports
|
|
270
|
-
|
|
271
271
|
exports.URL = URL
|
|
272
272
|
exports.URLSearchParams = URLSearchParams
|
|
273
273
|
|
|
@@ -279,6 +279,8 @@ exports.isURL = function isURL(value) {
|
|
|
279
279
|
return typeof value === 'object' && value !== null && value[kind] === URL[kind]
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
exports.isURLSearchParams = URLSearchParams.isURLSearchParams
|
|
283
|
+
|
|
282
284
|
// https://url.spec.whatwg.org/#dom-url-parse
|
|
283
285
|
exports.parse = function parse(input, base) {
|
|
284
286
|
const url = new URL(input, base, { throw: false })
|
|
@@ -16,4 +16,8 @@ declare class URLSearchParams {
|
|
|
16
16
|
constructor(init: string | Record<string, string> | Iterable<[string, string]>)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
declare namespace URLSearchParams {
|
|
20
|
+
export function isURLSearchParams(value: unknown): value is URLSearchParams
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
export = URLSearchParams
|
package/lib/url-search-params.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
const kind = Symbol.for('bare.url.search-params.kind')
|
|
2
|
+
|
|
3
|
+
class URLSearchParams {
|
|
2
4
|
static _urls = new WeakMap()
|
|
3
5
|
|
|
6
|
+
static get [kind]() {
|
|
7
|
+
return 0 // Compatibility version
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
|
|
5
11
|
constructor(init, url = null) {
|
|
6
12
|
this._params = new Map()
|
|
@@ -18,6 +24,10 @@ module.exports = class URLSearchParams {
|
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
|
|
27
|
+
get [kind]() {
|
|
28
|
+
return URLSearchParams[kind]
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
|
|
22
32
|
get size() {
|
|
23
33
|
return this._params.length
|
|
@@ -172,3 +182,11 @@ module.exports = class URLSearchParams {
|
|
|
172
182
|
return output
|
|
173
183
|
}
|
|
174
184
|
}
|
|
185
|
+
|
|
186
|
+
module.exports = exports = URLSearchParams
|
|
187
|
+
|
|
188
|
+
exports.isURLSearchParams = function isURLSearchParams(value) {
|
|
189
|
+
if (value instanceof URLSearchParams) return true
|
|
190
|
+
|
|
191
|
+
return typeof value === 'object' && value !== null && value[kind] === URLSearchParams[kind]
|
|
192
|
+
}
|