| 'use strict' | ||
| const test = require('tape') | ||
| const fastURI = require('..') | ||
| test('scheme is normalized to lowercase (RFC 3986 §6.2.2.1)', (t) => { | ||
| // parse lowercases the scheme, consistent with how it already lowercases the host | ||
| t.equal(fastURI.parse('HTTP://EXAMPLE.com/Path').scheme, 'http', 'parse lowercases an uppercase scheme') | ||
| t.equal(fastURI.parse('HtTpS://example.com').scheme, 'https', 'parse lowercases a mixed-case scheme') | ||
| // normalize emits a lowercase scheme (matches the already-lowercased host) | ||
| t.equal(fastURI.normalize('HTTP://EXAMPLE.com/p'), 'http://example.com/p', 'normalize lowercases the scheme') | ||
| t.equal(fastURI.normalize('HtTp://Example.COM/'), 'http://example.com/', 'normalize lowercases a mixed-case scheme') | ||
| t.end() | ||
| }) |
@@ -5,4 +5,13 @@ version: 2 | ||
| directory: "/" | ||
| commit-message: | ||
| # Prefix all commit messages with "chore: " | ||
| prefix: "chore" | ||
| schedule: | ||
| interval: "monthly" | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
| allow: | ||
| - dependency-name: "*" | ||
| update-types: | ||
| - "version-update:semver-major" | ||
| open-pull-requests-limit: 10 | ||
@@ -12,4 +21,35 @@ | ||
| directory: "/" | ||
| commit-message: | ||
| # Prefix all commit messages with "chore: " | ||
| prefix: "chore" | ||
| schedule: | ||
| interval: "monthly" | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
| versioning-strategy: "increase-if-necessary" | ||
| allow: | ||
| - dependency-name: "*" | ||
| update-types: | ||
| - "version-update:semver-major" | ||
| ignore: | ||
| # TODO: remove ignore until neostandard support ESLint 10 | ||
| - dependency-name: "eslint" | ||
| - dependency-name: "neostandard" | ||
| - dependency-name: "@stylistic/*" | ||
| open-pull-requests-limit: 10 | ||
| groups: | ||
| # Production dependencies with breaking changes | ||
| dependencies: | ||
| dependency-type: "production" | ||
| # ESLint related dependencies | ||
| dev-dependencies-eslint: | ||
| patterns: | ||
| - "eslint" | ||
| - "neostandard" | ||
| - "@stylistic/*" | ||
| # TypeScript related dependencies | ||
| dev-dependencies-typescript: | ||
| patterns: | ||
| - "@types/*" | ||
| - "tstyche" | ||
| - "typescript" |
@@ -33,3 +33,3 @@ name: CI | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
@@ -58,3 +58,3 @@ persist-credentials: false | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
@@ -82,3 +82,3 @@ persist-credentials: false | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
@@ -125,3 +125,3 @@ persist-credentials: false | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
@@ -128,0 +128,0 @@ persist-credentials: false |
+2
-2
@@ -255,3 +255,3 @@ 'use strict' | ||
| // store each component | ||
| parsed.scheme = matches[1] | ||
| parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase() | ||
| parsed.userinfo = matches[3] | ||
@@ -309,3 +309,3 @@ parsed.host = matches[4] | ||
| try { | ||
| parsed.host = URL.domainToASCII(parsed.host.toLowerCase()) | ||
| parsed.host = new URL('http://' + parsed.host).hostname | ||
| } catch (e) { | ||
@@ -312,0 +312,0 @@ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e |
+1
-1
| { | ||
| "name": "fast-uri", | ||
| "description": "Dependency-free RFC 3986 URI toolbox", | ||
| "version": "4.0.0", | ||
| "version": "4.0.1", | ||
| "main": "index.js", | ||
@@ -6,0 +6,0 @@ "type": "commonjs", |
+9
-9
@@ -30,6 +30,6 @@ # fast-uri | ||
| * `unicodeSupport` (boolean, false) | ||
| 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). | ||
| 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). | ||
| * `domainHost` (boolean, false) | ||
| 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). | ||
| 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). | ||
@@ -94,10 +94,10 @@ ### Parse | ||
| 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: | ||
| 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: | ||
| * http \[[RFC 2616](http://www.ietf.org/rfc/rfc2616.txt)\] | ||
| * https \[[RFC 2818](http://www.ietf.org/rfc/rfc2818.txt)\] | ||
| * ws \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\] | ||
| * wss \[[RFC 6455](http://www.ietf.org/rfc/rfc6455.txt)\] | ||
| * urn \[[RFC 2141](http://www.ietf.org/rfc/rfc2141.txt)\] | ||
| * urn:uuid \[[RFC 4122](http://www.ietf.org/rfc/rfc4122.txt)\] | ||
| * http \[[RFC 2616](https://www.ietf.org/rfc/rfc2616.txt)\] | ||
| * https \[[RFC 2818](https://www.ietf.org/rfc/rfc2818.txt)\] | ||
| * ws \[[RFC 6455](https://www.ietf.org/rfc/rfc6455.txt)\] | ||
| * wss \[[RFC 6455](https://www.ietf.org/rfc/rfc6455.txt)\] | ||
| * urn \[[RFC 2141](https://www.ietf.org/rfc/rfc2141.txt)\] | ||
| * urn:uuid \[[RFC 4122](https://www.ietf.org/rfc/rfc4122.txt)\] | ||
@@ -104,0 +104,0 @@ |
@@ -134,1 +134,29 @@ 'use strict' | ||
| }) | ||
| test('parse canonicalises IDN / Unicode hosts to their ASCII form', (t) => { | ||
| const cases = [ | ||
| { | ||
| input: 'http://127。0。0。1/', | ||
| expectedHost: '127.0.0.1', | ||
| description: 'full-width ideographic stops as octet separators' | ||
| }, | ||
| { | ||
| input: 'http://example.com/', | ||
| expectedHost: 'example.com', | ||
| description: 'fullwidth e as first letter' | ||
| }, | ||
| { | ||
| input: 'http://納豆.example.org/', | ||
| expectedHost: 'xn--99zt52a.example.org', | ||
| description: 'CJK label requiring punycode' | ||
| } | ||
| ] | ||
| t.plan(cases.length * 2) | ||
| cases.forEach(({ input, expectedHost, description }) => { | ||
| const parsed = fastURI.parse(input) | ||
| t.notOk(parsed.error, `parse should not set error: ${description}`) | ||
| t.equal(parsed.host, expectedHost, `host canonicalised to ASCII: ${description}`) | ||
| }) | ||
| }) |
@@ -11,3 +11,3 @@ 'use strict' | ||
| * @author <a href="mailto:gary.court@gmail.com">Gary Court</a> | ||
| * @see http://github.com/garycourt/uri-js | ||
| * @see https://github.com/garycourt/uri-js | ||
| */ | ||
@@ -14,0 +14,0 @@ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
171467
1.67%36
2.86%3990
0.94%