fast-uri 3.0.0 → 3.0.2

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.
@@ -17,7 +17,7 @@ on:
17
17
 
18
18
  jobs:
19
19
  test:
20
- uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.2.0
20
+ uses: fastify/workflows/.github/workflows/plugins-ci.yml@v5.0.0
21
21
  with:
22
22
  license-check: true
23
- node-versions: '["16", "18", "20"]'
23
+ node-versions: '["16", "18", "20", "22"]'
@@ -17,4 +17,4 @@ on:
17
17
 
18
18
  jobs:
19
19
  test:
20
- uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v4.1.0
20
+ uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v5.0.0
package/index.js CHANGED
@@ -135,8 +135,7 @@ function serialize (cmpts, opts) {
135
135
  }
136
136
 
137
137
  if (options.reference !== 'suffix' && components.scheme) {
138
- uriTokens.push(components.scheme)
139
- uriTokens.push(':')
138
+ uriTokens.push(components.scheme, ':')
140
139
  }
141
140
 
142
141
  const authority = recomposeAuthority(components, options)
@@ -166,13 +165,11 @@ function serialize (cmpts, opts) {
166
165
  }
167
166
 
168
167
  if (components.query !== undefined) {
169
- uriTokens.push('?')
170
- uriTokens.push(components.query)
168
+ uriTokens.push('?', components.query)
171
169
  }
172
170
 
173
171
  if (components.fragment !== undefined) {
174
- uriTokens.push('#')
175
- uriTokens.push(components.fragment)
172
+ uriTokens.push('#', components.fragment)
176
173
  }
177
174
  return uriTokens.join('')
178
175
  }
@@ -270,9 +267,6 @@ function parse (uri, opts) {
270
267
  if (gotEncoding && parsed.scheme !== undefined) {
271
268
  parsed.scheme = unescape(parsed.scheme)
272
269
  }
273
- if (gotEncoding && parsed.userinfo !== undefined) {
274
- parsed.userinfo = unescape(parsed.userinfo)
275
- }
276
270
  if (gotEncoding && parsed.host !== undefined) {
277
271
  parsed.host = unescape(parsed.host)
278
272
  }
@@ -280,7 +274,7 @@ function parse (uri, opts) {
280
274
  parsed.path = escape(unescape(parsed.path))
281
275
  }
282
276
  if (parsed.fragment !== undefined && parsed.fragment.length) {
283
- parsed.fragment = encodeURI(decodeURI(parsed.fragment))
277
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment))
284
278
  }
285
279
  }
286
280
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fast-uri",
3
3
  "description": "Dependency free RFC 3986 URI toolbox",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
7
7
  "types": "types/index.d.ts",
@@ -21,17 +21,18 @@
21
21
  "lint:fix": "standard --fix",
22
22
  "test": "npm run lint && npm run test:unit && npm run test:typescript",
23
23
  "test:ci": "npm run lint && npm run test:unit -- --coverage-report=lcovonly && npm run test:typescript",
24
- "test:unit": "tap",
24
+ "test:unit": "npx tape test/**/*.js",
25
25
  "test:unit:dev": "npm run test:unit -- --coverage-report=html",
26
26
  "test:typescript": "tsd"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@fastify/pre-commit": "^2.1.0",
30
+ "ajv": "^8.16.0",
30
31
  "benchmark": "^2.1.4",
31
32
  "coveralls": "^3.1.1",
32
33
  "snazzy": "^9.0.0",
33
34
  "standard": "^17.1.0",
34
- "tap": "^18.7.2",
35
+ "tape": "^5.8.1",
35
36
  "tsd": "^0.31.0",
36
37
  "uri-js": "^4.4.1"
37
38
  }
@@ -0,0 +1,39 @@
1
+ const AJV = require('ajv')
2
+ const fastUri = require('../')
3
+ const ajv = new AJV({
4
+ uriResolver: fastUri // comment this line to see it works with uri-js
5
+ })
6
+ const test = require('tape')
7
+
8
+ test('ajv', t => {
9
+ t.plan(1)
10
+ const schema = {
11
+ $ref: '#/definitions/Record%3Cstring%2CPerson%3E',
12
+ definitions: {
13
+ Person: {
14
+ type: 'object',
15
+ properties: {
16
+ firstName: {
17
+ type: 'string'
18
+ }
19
+ }
20
+ },
21
+ 'Record<string,Person>': {
22
+ type: 'object',
23
+ additionalProperties: {
24
+ $ref: '#/definitions/Person'
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ const data = {
31
+ joe: {
32
+ firstName: 'Joe'
33
+ }
34
+
35
+ }
36
+
37
+ const validate = ajv.compile(schema)
38
+ t.ok(validate(data))
39
+ })
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const tap = require('tap')
4
- const test = tap.test
3
+ const test = require('tape')
5
4
  const fastifyURI = require('../')
6
5
  const urijs = require('uri-js')
7
6
 
@@ -18,6 +17,8 @@ test('compatibility Parse', (t) => {
18
17
  '//[2001:db8::001]:80',
19
18
  'uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body',
20
19
  'http://user:pass@example.com:123/one/space in.url?q1=a1&q2=a2#body',
20
+ 'http://User:Pass@example.com:123/one/space in.url?q1=a1&q2=a2#body',
21
+ 'http://A%3AB@example.com:123/one/space',
21
22
  '//[::ffff:129.144.52.38]',
22
23
  'uri://10.10.10.10.example.com/en/process',
23
24
  '//[2606:2800:220:1:248:1893:25c8:1946]/test',
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const tap = require('tap')
4
- const test = tap.test
3
+ const test = require('tape')
5
4
  const URI = require('../')
6
5
 
7
6
  const fn = URI.equal
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const tap = require('tap')
4
- const test = tap.test
3
+ const test = require('tape')
5
4
  const URI = require('../')
6
5
 
7
6
  test('URI parse', (t) => {
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const tap = require('tap')
4
- const test = tap.test
3
+ const test = require('tape')
5
4
  const URI = require('../')
6
5
 
7
6
  test('URI Resolving', (t) => {
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const tap = require('tap')
4
- const test = tap.test
3
+ const test = require('tape')
5
4
  const URI = require('../')
6
5
 
7
6
  test('URI Serialize', (t) => {