fast-uri 4.1.1 → 4.1.3
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/.github/workflows/ci.yml +9 -9
- package/.github/workflows/lock-threads.yml +1 -1
- package/.github/workflows/ossf-scorecard.yml +45 -0
- package/README.md +1 -0
- package/SECURITY.md +173 -0
- package/benchmark/benchmark.mjs +71 -0
- package/index.js +236 -42
- package/lib/schemes.js +384 -7
- package/lib/utils.js +302 -88
- package/package.json +1 -1
- package/test/component-safe-serialization.test.js +105 -0
- package/test/equal.test.js +43 -3
- package/test/fixtures/uri-js-parse.json +24 -1
- package/test/fixtures/uri-js-serialize.json +23 -1
- package/test/ipv6-canonical.test.js +34 -0
- package/test/ipv6-validation.test.js +90 -0
- package/test/malformed-percent.test.js +77 -0
- package/test/malformed-urn.test.js +61 -0
- package/test/parse.test.js +145 -0
- package/test/reserved-path-normalization.test.js +109 -0
- package/test/scheme-validation.test.js +122 -0
- package/test/security-normalization.test.js +101 -0
- package/test/security-utf8-encoding.test.js +0 -0
- package/test/security.test.js +211 -3
- package/test/serialize.test.js +144 -0
- package/test/uri-js-compatibility.test.js +0 -3
- package/test/uri-js.test.js +3 -3
- package/test/urn-full-input.test.js +29 -0
- package/test/websocket-query-preservation.test.js +24 -0
- package/types/index.d.ts +4 -0
- package/types/index.tst.ts +16 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const test = require('tape')
|
|
4
|
+
const fastURI = require('..')
|
|
5
|
+
|
|
6
|
+
test('WebSocket queries preserve additional question marks', (t) => {
|
|
7
|
+
for (const scheme of ['ws', 'wss']) {
|
|
8
|
+
const uri = `${scheme}://example.com/chat?a?b`
|
|
9
|
+
const truncatedURI = `${scheme}://example.com/chat?a`
|
|
10
|
+
const parsed = fastURI.parse(uri)
|
|
11
|
+
|
|
12
|
+
t.equal(parsed.resourceName, '/chat?a?b', `${scheme} parse preserves the resource name`)
|
|
13
|
+
t.equal(fastURI.serialize(parsed), uri, `${scheme} parsed components round-trip`)
|
|
14
|
+
t.equal(
|
|
15
|
+
fastURI.serialize({ scheme, host: 'example.com', resourceName: '/chat?a?b' }),
|
|
16
|
+
uri,
|
|
17
|
+
`${scheme} resource name serializes without truncation`
|
|
18
|
+
)
|
|
19
|
+
t.equal(fastURI.normalize(uri), uri, `${scheme} normalization preserves the full query`)
|
|
20
|
+
t.equal(fastURI.equal(uri, truncatedURI), false, `${scheme} equality distinguishes the full query`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
t.end()
|
|
24
|
+
})
|
package/types/index.d.ts
CHANGED
package/types/index.tst.ts
CHANGED
|
@@ -13,3 +13,19 @@ const parsed2 = uri.parse('foo', {
|
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
expect(parsed2).type.toBe<URIComponent>()
|
|
16
|
+
|
|
17
|
+
const mailtoComponent: URIComponent = {
|
|
18
|
+
scheme: 'mailto',
|
|
19
|
+
to: ['user@example.org'],
|
|
20
|
+
subject: 'Hello',
|
|
21
|
+
body: 'Message',
|
|
22
|
+
headers: { cc: 'other@example.org' }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
expect(uri.serialize(mailtoComponent, { unicodeSupport: true })).type.toBe<string>()
|
|
26
|
+
|
|
27
|
+
const parsedMailto = uri.parse('mailto:user@example.org')
|
|
28
|
+
expect(parsedMailto.to).type.toBe<string[] | undefined>()
|
|
29
|
+
expect(parsedMailto.subject).type.toBe<string | undefined>()
|
|
30
|
+
expect(parsedMailto.body).type.toBe<string | undefined>()
|
|
31
|
+
expect(parsedMailto.headers).type.toBe<{ [hfname: string]: string } | undefined>()
|