fast-uri 4.0.0 → 4.0.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.
@@ -2,12 +2,52 @@ version: 2
2
2
  updates:
3
3
  - package-ecosystem: "github-actions"
4
4
  directory: "/"
5
+ commit-message:
6
+ # Prefix all commit messages with "chore: "
7
+ prefix: "chore"
5
8
  schedule:
6
- interval: "monthly"
9
+ interval: "weekly"
10
+ cooldown:
11
+ default-days: 7
12
+ allow:
13
+ - dependency-name: "*"
14
+ update-types:
15
+ - "version-update:semver-major"
7
16
  open-pull-requests-limit: 10
8
17
 
9
18
  - package-ecosystem: "npm"
10
19
  directory: "/"
20
+ commit-message:
21
+ # Prefix all commit messages with "chore: "
22
+ prefix: "chore"
11
23
  schedule:
12
- interval: "monthly"
24
+ interval: "weekly"
25
+ cooldown:
26
+ default-days: 7
27
+ versioning-strategy: "increase-if-necessary"
28
+ allow:
29
+ - dependency-name: "*"
30
+ update-types:
31
+ - "version-update:semver-major"
32
+ ignore:
33
+ # TODO: remove ignore until neostandard support ESLint 10
34
+ - dependency-name: "eslint"
35
+ - dependency-name: "neostandard"
36
+ - dependency-name: "@stylistic/*"
13
37
  open-pull-requests-limit: 10
38
+ groups:
39
+ # Production dependencies with breaking changes
40
+ dependencies:
41
+ dependency-type: "production"
42
+ # ESLint related dependencies
43
+ dev-dependencies-eslint:
44
+ patterns:
45
+ - "eslint"
46
+ - "neostandard"
47
+ - "@stylistic/*"
48
+ # TypeScript related dependencies
49
+ dev-dependencies-typescript:
50
+ patterns:
51
+ - "@types/*"
52
+ - "tstyche"
53
+ - "typescript"
@@ -30,7 +30,7 @@ jobs:
30
30
  matrix:
31
31
  node-version: ['20', '22', '24', '26']
32
32
  steps:
33
- - uses: actions/checkout@v6
33
+ - uses: actions/checkout@v7
34
34
  with:
35
35
  persist-credentials: false
36
36
 
@@ -54,7 +54,7 @@ jobs:
54
54
  matrix:
55
55
  node-version: ['16', '18', '20', '22', '24', '26']
56
56
  steps:
57
- - uses: actions/checkout@v6
57
+ - uses: actions/checkout@v7
58
58
  with:
59
59
  persist-credentials: false
60
60
 
@@ -77,7 +77,7 @@ jobs:
77
77
  permissions:
78
78
  contents: read
79
79
  steps:
80
- - uses: actions/checkout@v6
80
+ - uses: actions/checkout@v7
81
81
  with:
82
82
  persist-credentials: false
83
83
 
@@ -119,7 +119,7 @@ jobs:
119
119
  permissions:
120
120
  contents: read
121
121
  steps:
122
- - uses: actions/checkout@v6
122
+ - uses: actions/checkout@v7
123
123
  with:
124
124
  persist-credentials: false
125
125
 
package/README.md CHANGED
@@ -27,10 +27,10 @@ Malformed authorities and out-of-range ports are reported through the parsed com
27
27
  If set to `true`, the serializer will not resolve a relative `path` component.
28
28
 
29
29
  * `unicodeSupport` (boolean, false)
30
- If set to `true`, the parser will unescape non-ASCII characters in the parsed output as per [RFC 3987](http://www.ietf.org/rfc/rfc3987.txt).
30
+ If set to `true`, the parser will unescape non-ASCII characters in the parsed output as per [RFC 3987](https://www.ietf.org/rfc/rfc3987.txt).
31
31
 
32
32
  * `domainHost` (boolean, false)
33
- If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](http://www.ietf.org/rfc/rfc5891.txt).
33
+ If set to `true`, the library will treat the `host` component as a domain name, and convert IDNs (International Domain Names) as per [RFC 5891](https://www.ietf.org/rfc/rfc5891.txt).
34
34
 
35
35
  ### Parse
36
36
 
@@ -90,14 +90,14 @@ true
90
90
 
91
91
  ## Scheme supports
92
92
 
93
- fast-uri supports inserting custom [scheme](http://en.wikipedia.org/wiki/URI_scheme)-dependent processing rules. Currently, fast-uri has built-in support for the following schemes:
93
+ fast-uri supports inserting custom [scheme](https://en.wikipedia.org/wiki/URI_scheme)-dependent processing rules. Currently, fast-uri has built-in support for the following schemes:
94
94
 
95
- * http \[[RFC 2616](http://www.ietf.org/rfc/rfc2616.txt)\]
96
- * https \[[RFC 2818](http://www.ietf.org/rfc/rfc2818.txt)\]
97
- * ws \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
98
- * wss \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\]
99
- * urn \[[RFC 2141](http://www.ietf.org/rfc/rfc2141.txt)\]
100
- * urn:uuid \[[RFC 4122](http://www.ietf.org/rfc/rfc4122.txt)\]
95
+ * http \[[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)\]
96
+ * https \[[RFC 2818](https://www.ietf.org/rfc/rfc2818.txt)\]
97
+ * ws \[[RFC 6455](https://www.ietf.org/rfc/rfc6455.txt)\]
98
+ * wss \[[RFC 6455](https://www.ietf.org/rfc/rfc6455.txt)\]
99
+ * urn \[[RFC 2141](https://www.ietf.org/rfc/rfc2141.txt)\]
100
+ * urn:uuid \[[RFC 4122](https://www.ietf.org/rfc/rfc4122.txt)\]
101
101
 
102
102
 
103
103
  ## Benchmarks
package/index.js CHANGED
@@ -252,7 +252,7 @@ function parseWithStatus (uri, opts) {
252
252
 
253
253
  if (matches) {
254
254
  // store each component
255
- parsed.scheme = matches[1]
255
+ parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase()
256
256
  parsed.userinfo = matches[3]
257
257
  parsed.host = matches[4]
258
258
  parsed.port = parseInt(matches[5], 10)
@@ -305,7 +305,7 @@ function parseWithStatus (uri, opts) {
305
305
  if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && isIP === false && nonSimpleDomain(parsed.host)) {
306
306
  // convert Unicode IDN -> ASCII IDN
307
307
  try {
308
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase())
308
+ parsed.host = new URL('http://' + parsed.host).hostname
309
309
  } catch (e) {
310
310
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e
311
311
  }
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": "4.0.0",
4
+ "version": "4.0.1",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
7
7
  "types": "types/index.d.ts",
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ test('scheme is normalized to lowercase (RFC 3986 §6.2.2.1)', (t) => {
7
+ // parse lowercases the scheme, consistent with how it already lowercases the host
8
+ t.equal(fastURI.parse('HTTP://EXAMPLE.com/Path').scheme, 'http', 'parse lowercases an uppercase scheme')
9
+ t.equal(fastURI.parse('HtTpS://example.com').scheme, 'https', 'parse lowercases a mixed-case scheme')
10
+
11
+ // normalize emits a lowercase scheme (matches the already-lowercased host)
12
+ t.equal(fastURI.normalize('HTTP://EXAMPLE.com/p'), 'http://example.com/p', 'normalize lowercases the scheme')
13
+ t.equal(fastURI.normalize('HtTp://Example.COM/'), 'http://example.com/', 'normalize lowercases a mixed-case scheme')
14
+
15
+ t.end()
16
+ })
@@ -131,3 +131,31 @@ test('normalize does not double-decode %2540 into a live @', (t) => {
131
131
  t.plan(1)
132
132
  t.notEqual(parsed.host, 'trusted.com@evil.com', 'http://trusted.com%2540evil.com/')
133
133
  })
134
+
135
+ test('parse canonicalises IDN / Unicode hosts to their ASCII form', (t) => {
136
+ const cases = [
137
+ {
138
+ input: 'http://127。0。0。1/',
139
+ expectedHost: '127.0.0.1',
140
+ description: 'full-width ideographic stops as octet separators'
141
+ },
142
+ {
143
+ input: 'http://example.com/',
144
+ expectedHost: 'example.com',
145
+ description: 'fullwidth e as first letter'
146
+ },
147
+ {
148
+ input: 'http://納豆.example.org/',
149
+ expectedHost: 'xn--99zt52a.example.org',
150
+ description: 'CJK label requiring punycode'
151
+ }
152
+ ]
153
+
154
+ t.plan(cases.length * 2)
155
+
156
+ cases.forEach(({ input, expectedHost, description }) => {
157
+ const parsed = fastURI.parse(input)
158
+ t.notOk(parsed.error, `parse should not set error: ${description}`)
159
+ t.equal(parsed.host, expectedHost, `host canonicalised to ASCII: ${description}`)
160
+ })
161
+ })
@@ -8,7 +8,7 @@ const fastURI = require('..')
8
8
  *
9
9
  * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/normalizing/resolving/serializing library for JavaScript.
10
10
  * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
11
- * @see http://github.com/garycourt/uri-js
11
+ * @see https://github.com/garycourt/uri-js
12
12
  */
13
13
 
14
14
  /**