bare-url 2.3.2 → 2.4.1

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/binding.c CHANGED
@@ -8,8 +8,6 @@
8
8
  #include <utf.h>
9
9
  #include <utf/string.h>
10
10
 
11
- static js_type_tag_t bare_url__tag = {0x6f1fd92f476698b0, 0x93b59c349143ee50};
12
-
13
11
  static js_value_t *
14
12
  bare_url_parse (js_env_t *env, js_callback_info_t *info) {
15
13
  int err;
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
- module.exports = exports = class URL {
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
@@ -1,6 +1,12 @@
1
- module.exports = class URLSearchParams {
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
@@ -135,9 +145,11 @@ module.exports = class URLSearchParams {
135
145
 
136
146
  this._params = new Map()
137
147
 
138
- for (const sequence of input.split('&')) {
148
+ for (let sequence of input.split('&')) {
139
149
  if (sequence.length === 0) continue
140
150
 
151
+ sequence = sequence.replace(/\+/g, ' ')
152
+
141
153
  let i = sequence.indexOf('=')
142
154
  if (i === -1) i = sequence.length
143
155
 
@@ -172,3 +184,11 @@ module.exports = class URLSearchParams {
172
184
  return output
173
185
  }
174
186
  }
187
+
188
+ module.exports = exports = URLSearchParams
189
+
190
+ exports.isURLSearchParams = function isURLSearchParams(value) {
191
+ if (value instanceof URLSearchParams) return true
192
+
193
+ return typeof value === 'object' && value !== null && value[kind] === URLSearchParams[kind]
194
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-url",
3
- "version": "2.3.2",
3
+ "version": "2.4.1",
4
4
  "description": "WHATWG URL implementation for JavaScript",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -26,7 +26,9 @@
26
26
  ],
27
27
  "addon": true,
28
28
  "scripts": {
29
- "test": "prettier . --check && bare test.js"
29
+ "format": "prettier --write . && lunte --fix",
30
+ "lint": "prettier --check . && lunte",
31
+ "test": "brittle-bare --coverage test.js"
30
32
  },
31
33
  "repository": {
32
34
  "type": "git",
@@ -45,6 +47,7 @@
45
47
  "brittle": "^3.3.2",
46
48
  "cmake-bare": "^1.1.6",
47
49
  "cmake-fetch": "^1.0.0",
50
+ "lunte": "^1.6.0",
48
51
  "prettier": "^3.3.3",
49
52
  "prettier-config-holepunch": "^2.0.0"
50
53
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file