@suveren/gateway 0.7.4 → 0.8.0

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.
Files changed (264) hide show
  1. package/content/integrations/mollie.json +103 -28
  2. package/dist/control-plane/index.mjs +248 -58
  3. package/dist/mcp-server/http.mjs +577 -124
  4. package/dist/ui/assets/index-BFnSVa9N.js +110 -0
  5. package/dist/ui/assets/{index-CkWaRck1.css → index-BYVb_0oG.css} +1 -1
  6. package/dist/ui/index.html +2 -2
  7. package/node_modules/@hap/core/dist/index.d.mts +285 -13
  8. package/node_modules/@hap/core/dist/index.d.ts +285 -13
  9. package/node_modules/@hap/core/dist/index.js +281 -13
  10. package/node_modules/@hap/core/dist/index.mjs +266 -12
  11. package/node_modules/@hap/core/package.json +4 -2
  12. package/node_modules/@hap/core/src/did-key.ts +126 -0
  13. package/node_modules/@hap/core/src/frame.ts +115 -14
  14. package/node_modules/@hap/core/src/gatekeeper.ts +26 -0
  15. package/node_modules/@hap/core/src/identity.ts +21 -5
  16. package/node_modules/@hap/core/src/index.ts +3 -0
  17. package/node_modules/@hap/core/src/mandate.ts +207 -0
  18. package/node_modules/@hap/core/src/receipt.ts +74 -0
  19. package/node_modules/@hap/core/src/types.ts +87 -5
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/accept.js +54 -0
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/charset.js +10 -34
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/encoding.js +9 -30
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/language.js +15 -36
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/lib/mediaType.js +16 -134
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  29. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  30. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  31. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/package.json +16 -10
  32. package/node_modules/@types/node/README.md +1 -1
  33. package/node_modules/@types/node/buffer.buffer.d.ts +10 -5
  34. package/node_modules/@types/node/crypto.d.ts +2 -4
  35. package/node_modules/@types/node/dgram.d.ts +119 -4
  36. package/node_modules/@types/node/ffi.d.ts +1 -1
  37. package/node_modules/@types/node/fs/promises.d.ts +61 -65
  38. package/node_modules/@types/node/fs.d.ts +86 -76
  39. package/node_modules/@types/node/http.d.ts +17 -1
  40. package/node_modules/@types/node/http2.d.ts +12 -4
  41. package/node_modules/@types/node/index.d.ts +1 -0
  42. package/node_modules/@types/node/inspector.d.ts +2 -1
  43. package/node_modules/@types/node/net.d.ts +108 -16
  44. package/node_modules/@types/node/package.json +2 -2
  45. package/node_modules/@types/node/process.d.ts +52 -0
  46. package/node_modules/@types/node/quic.d.ts +246 -38
  47. package/node_modules/@types/node/sqlite.d.ts +6 -2
  48. package/node_modules/@types/node/stream/iter.d.ts +4 -4
  49. package/node_modules/@types/node/test.d.ts +36 -0
  50. package/node_modules/@types/node/tls.d.ts +24 -0
  51. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +5 -0
  52. package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
  53. package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
  54. package/node_modules/@types/node/tty.d.ts +4 -3
  55. package/node_modules/@types/node/vfs.d.ts +210 -0
  56. package/node_modules/@types/node/vm.d.ts +1 -1
  57. package/node_modules/express-rate-limit/dist/index.cjs +6 -3
  58. package/node_modules/express-rate-limit/dist/index.d.cts +11 -0
  59. package/node_modules/express-rate-limit/dist/index.d.mts +11 -0
  60. package/node_modules/express-rate-limit/dist/index.d.ts +11 -0
  61. package/node_modules/express-rate-limit/dist/index.mjs +6 -3
  62. package/node_modules/express-rate-limit/{license.md → license} +7 -6
  63. package/node_modules/express-rate-limit/package.json +5 -5
  64. package/node_modules/express-rate-limit/readme.md +1 -0
  65. package/node_modules/fast-uri/index.js +215 -47
  66. package/node_modules/fast-uri/lib/schemes.js +9 -4
  67. package/node_modules/fast-uri/lib/utils.js +396 -92
  68. package/node_modules/fast-uri/package.json +1 -1
  69. package/node_modules/fast-uri/test/component-safe-serialization.test.js +163 -0
  70. package/node_modules/fast-uri/test/equal.test.js +31 -3
  71. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  72. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  73. package/node_modules/fast-uri/test/ipv6-validation.test.js +124 -0
  74. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  75. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  76. package/node_modules/fast-uri/test/parse.test.js +7 -3
  77. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  78. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  79. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  80. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  81. package/node_modules/fast-uri/test/security.test.js +75 -3
  82. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  83. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  84. package/node_modules/hono/dist/cjs/client/client.js +25 -11
  85. package/node_modules/hono/dist/cjs/client/utils.js +4 -1
  86. package/node_modules/hono/dist/cjs/context.js +4 -0
  87. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
  88. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +1 -1
  89. package/node_modules/hono/dist/cjs/helper/ssg/utils.js +30 -10
  90. package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
  91. package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
  92. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  93. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  94. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  95. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -3
  96. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  97. package/node_modules/hono/dist/cjs/request.js +8 -4
  98. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  99. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  100. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
  101. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
  102. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
  103. package/node_modules/hono/dist/cjs/router/trie-router/node.js +46 -69
  104. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  105. package/node_modules/hono/dist/cjs/router/utils.js +27 -0
  106. package/node_modules/hono/dist/cjs/utils/body.js +15 -3
  107. package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
  108. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  109. package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
  110. package/node_modules/hono/dist/cjs/utils/url.js +9 -1
  111. package/node_modules/hono/dist/client/client.js +25 -11
  112. package/node_modules/hono/dist/client/utils.js +4 -1
  113. package/node_modules/hono/dist/context.js +4 -0
  114. package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
  115. package/node_modules/hono/dist/helper/ssg/ssg.js +1 -1
  116. package/node_modules/hono/dist/helper/ssg/utils.js +30 -10
  117. package/node_modules/hono/dist/jsx/dom/render.js +2 -0
  118. package/node_modules/hono/dist/middleware/cache/index.js +1 -1
  119. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  120. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  121. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  122. package/node_modules/hono/dist/middleware/etag/index.js +3 -3
  123. package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
  124. package/node_modules/hono/dist/request.js +8 -4
  125. package/node_modules/hono/dist/router/linear-router/router.js +7 -2
  126. package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
  127. package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
  128. package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
  129. package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
  130. package/node_modules/hono/dist/router/trie-router/node.js +46 -69
  131. package/node_modules/hono/dist/router/trie-router/router.js +3 -11
  132. package/node_modules/hono/dist/router/utils.js +5 -0
  133. package/node_modules/hono/dist/types/context.d.ts +4 -0
  134. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
  135. package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
  136. package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
  137. package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
  138. package/node_modules/hono/dist/types/utils/url.d.ts +4 -0
  139. package/node_modules/hono/dist/utils/body.js +15 -3
  140. package/node_modules/hono/dist/utils/cookie.js +1 -1
  141. package/node_modules/hono/dist/utils/ipaddr.js +5 -3
  142. package/node_modules/hono/dist/utils/stream.js +7 -1
  143. package/node_modules/hono/dist/utils/url.js +9 -1
  144. package/node_modules/hono/package.json +1 -1
  145. package/node_modules/ip-address/README.md +92 -82
  146. package/node_modules/ip-address/dist/common.d.ts +20 -0
  147. package/node_modules/ip-address/dist/common.js +36 -0
  148. package/node_modules/ip-address/dist/common.js.map +1 -1
  149. package/node_modules/ip-address/dist/ipv4.d.ts +50 -0
  150. package/node_modules/ip-address/dist/ipv4.js +75 -0
  151. package/node_modules/ip-address/dist/ipv4.js.map +1 -1
  152. package/node_modules/ip-address/dist/ipv6.d.ts +79 -10
  153. package/node_modules/ip-address/dist/ipv6.js +120 -30
  154. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  155. package/node_modules/ip-address/dist/v4/constants.d.ts +12 -0
  156. package/node_modules/ip-address/dist/v4/constants.js +40 -1
  157. package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
  158. package/node_modules/ip-address/dist/v6/constants.d.ts +14 -0
  159. package/node_modules/ip-address/dist/v6/constants.js +47 -1
  160. package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
  161. package/node_modules/ip-address/package.json +1 -1
  162. package/node_modules/is-plain-object/README.md +39 -95
  163. package/node_modules/is-plain-object/dist/is-plain-object.js +0 -2
  164. package/node_modules/is-plain-object/is-plain-object.d.ts +6 -1
  165. package/node_modules/is-plain-object/package.json +8 -34
  166. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +7 -16
  167. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +10 -20
  168. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +7 -16
  169. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +16 -38
  170. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +7 -16
  171. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +19 -38
  172. package/node_modules/jose/dist/types/jwk/embedded.d.ts +3 -8
  173. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +5 -5
  174. package/node_modules/jose/dist/types/jwks/local.d.ts +6 -10
  175. package/node_modules/jose/dist/types/jwks/remote.d.ts +17 -28
  176. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -10
  177. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +9 -18
  178. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +7 -16
  179. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +9 -18
  180. package/node_modules/jose/dist/types/jws/general/sign.d.ts +11 -21
  181. package/node_modules/jose/dist/types/jws/general/verify.d.ts +12 -21
  182. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +10 -20
  183. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +17 -29
  184. package/node_modules/jose/dist/types/jwt/sign.d.ts +12 -19
  185. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +17 -28
  186. package/node_modules/jose/dist/types/jwt/verify.d.ts +9 -19
  187. package/node_modules/jose/dist/types/key/export.d.ts +4 -4
  188. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +6 -8
  189. package/node_modules/jose/dist/types/key/generate_secret.d.ts +4 -11
  190. package/node_modules/jose/dist/types/key/import.d.ts +10 -17
  191. package/node_modules/jose/dist/types/types.d.ts +48 -86
  192. package/node_modules/jose/dist/types/util/base64url.d.ts +2 -2
  193. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +3 -10
  194. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +4 -4
  195. package/node_modules/jose/dist/types/util/errors.d.ts +26 -53
  196. package/node_modules/jose/dist/webapi/index.js +70 -32
  197. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +7 -8
  198. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +42 -26
  199. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +14 -10
  200. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +53 -71
  201. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +38 -49
  202. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +121 -158
  203. package/node_modules/jose/dist/webapi/jwk/embedded.js +30 -18
  204. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +54 -64
  205. package/node_modules/jose/dist/webapi/jwks/local.js +49 -74
  206. package/node_modules/jose/dist/webapi/jwks/remote.js +91 -160
  207. package/node_modules/jose/dist/webapi/jws/compact/sign.js +21 -20
  208. package/node_modules/jose/dist/webapi/jws/compact/verify.js +7 -8
  209. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +29 -30
  210. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +21 -23
  211. package/node_modules/jose/dist/webapi/jws/general/sign.js +61 -70
  212. package/node_modules/jose/dist/webapi/jws/general/verify.js +47 -41
  213. package/node_modules/jose/dist/webapi/jwt/decrypt.js +13 -22
  214. package/node_modules/jose/dist/webapi/jwt/encrypt.js +58 -100
  215. package/node_modules/jose/dist/webapi/jwt/sign.js +18 -50
  216. package/node_modules/jose/dist/webapi/jwt/unsecured.js +34 -63
  217. package/node_modules/jose/dist/webapi/jwt/verify.js +12 -14
  218. package/node_modules/jose/dist/webapi/key/export.js +32 -37
  219. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +40 -44
  220. package/node_modules/jose/dist/webapi/key/generate_secret.js +35 -39
  221. package/node_modules/jose/dist/webapi/key/import.js +52 -52
  222. package/node_modules/jose/dist/webapi/lib/asn1.js +130 -164
  223. package/node_modules/jose/dist/webapi/lib/base64.js +18 -20
  224. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +34 -38
  225. package/node_modules/jose/dist/webapi/lib/content_encryption.js +79 -123
  226. package/node_modules/jose/dist/webapi/lib/crypto_key.js +24 -25
  227. package/node_modules/jose/dist/webapi/lib/deflate.js +46 -40
  228. package/node_modules/jose/dist/webapi/lib/helpers.js +40 -37
  229. package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +10 -24
  230. package/node_modules/jose/dist/webapi/lib/is_key_like.js +17 -15
  231. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +106 -93
  232. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +210 -176
  233. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +105 -107
  234. package/node_modules/jose/dist/webapi/lib/jwk_metadata.js +19 -0
  235. package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +9 -16
  236. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +62 -61
  237. package/node_modules/jose/dist/webapi/lib/jws_sign.js +58 -72
  238. package/node_modules/jose/dist/webapi/lib/jws_verify.js +90 -103
  239. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +134 -185
  240. package/node_modules/jose/dist/webapi/lib/key.js +84 -121
  241. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +13 -8
  242. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +8 -6
  243. package/node_modules/jose/dist/webapi/lib/key_management.js +200 -225
  244. package/node_modules/jose/dist/webapi/lib/key_options.js +8 -0
  245. package/node_modules/jose/dist/webapi/lib/options.js +57 -44
  246. package/node_modules/jose/dist/webapi/lib/signing.js +18 -22
  247. package/node_modules/jose/dist/webapi/lib/type_checks.js +28 -33
  248. package/node_modules/jose/dist/webapi/util/base64url.js +26 -35
  249. package/node_modules/jose/dist/webapi/util/decode_jwt.js +32 -31
  250. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +18 -23
  251. package/node_modules/jose/dist/webapi/util/errors.js +94 -84
  252. package/node_modules/jose/package.json +17 -81
  253. package/package.json +2 -2
  254. package/profiles/calendar/0.5.profile.json +190 -0
  255. package/profiles/charge/0.5.profile.json +210 -0
  256. package/profiles/customers/0.7.profile.json +157 -0
  257. package/profiles/deploy/0.9.profile.json +176 -0
  258. package/profiles/email/0.6.profile.json +208 -0
  259. package/profiles/index.json +9 -1
  260. package/profiles/publish/0.5.profile.json +186 -0
  261. package/profiles/purchase/0.5.profile.json +231 -0
  262. package/profiles/records/0.5.profile.json +117 -0
  263. package/dist/ui/assets/index-0Q2eNytX.js +0 -110
  264. package/node_modules/@modelcontextprotocol/sdk/node_modules/negotiator/HISTORY.md +0 -114
@@ -0,0 +1,163 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ test('userinfo serialization cannot terminate the authority', (t) => {
7
+ const uri = fastURI.serialize({
8
+ scheme: 'http',
9
+ userinfo: 'attacker.example/',
10
+ host: 'trusted.example',
11
+ path: '/'
12
+ })
13
+
14
+ t.equal(uri, 'http://attacker.example%2F@trusted.example/', 'slash is encoded as userinfo data')
15
+
16
+ const reparsed = fastURI.parse(uri)
17
+ t.equal(reparsed.host, 'trusted.example', 'reparsing retains the supplied host')
18
+ t.equal(reparsed.userinfo, 'attacker.example%2F', 'encoded slash remains in userinfo')
19
+ t.equal(
20
+ fastURI.serialize({ userinfo: 'user@/?:#[]\\', host: 'example.test' }),
21
+ '//user%40%2F%3F:%23%5B%5D%5C@example.test',
22
+ 'all userinfo component delimiters are encoded as data'
23
+ )
24
+ t.end()
25
+ })
26
+
27
+ test('port serialization rejects non-digit values', (t) => {
28
+ const malformedPorts = [
29
+ '@127.0.0.1:8124',
30
+ '8080@evil.example',
31
+ '8080/path',
32
+ '8080?query',
33
+ '8080#fragment',
34
+ '8080:9000',
35
+ '-1',
36
+ '1.5',
37
+ 1.5,
38
+ NaN,
39
+ Infinity,
40
+ '\u0661'
41
+ ]
42
+
43
+ for (const port of malformedPorts) {
44
+ t.throws(
45
+ () => fastURI.serialize({ scheme: 'http', host: 'trusted.example', port, path: '/app' }),
46
+ /URI port is malformed\./,
47
+ String(port)
48
+ )
49
+ }
50
+
51
+ t.throws(
52
+ () => fastURI.normalize({ scheme: 'http', host: 'trusted.example', port: '@evil.example' }),
53
+ /URI port is malformed\./,
54
+ 'object normalization rejects a malformed port'
55
+ )
56
+ t.equal(
57
+ fastURI.equal(
58
+ { scheme: 'http', host: 'trusted.example', port: '@evil.example' },
59
+ { scheme: 'http', host: 'trusted.example', port: '@evil.example' }
60
+ ),
61
+ false,
62
+ 'object equality fails closed for a malformed port'
63
+ )
64
+ t.end()
65
+ })
66
+
67
+ test('port serialization preserves RFC 3986 digit values', (t) => {
68
+ const validPorts = [
69
+ [8080, '8080'],
70
+ ['8080', '8080'],
71
+ ['00080', '00080'],
72
+ ['', '']
73
+ ]
74
+
75
+ for (const [port, expected] of validPorts) {
76
+ t.equal(
77
+ fastURI.serialize({ scheme: 'uri', host: 'example.test', port }),
78
+ `uri://example.test:${expected}`,
79
+ JSON.stringify(port)
80
+ )
81
+ }
82
+ t.end()
83
+ })
84
+
85
+ test('query and fragment serialization cannot inject component delimiters', (t) => {
86
+ const uri = fastURI.serialize({
87
+ scheme: 'x',
88
+ path: '/resource',
89
+ query: 'key=value#still-query',
90
+ fragment: 'first#still-fragment'
91
+ })
92
+
93
+ t.equal(
94
+ uri,
95
+ 'x:/resource?key=value%23still-query#first%23still-fragment',
96
+ 'raw hashes are encoded within their supplied components'
97
+ )
98
+
99
+ const reparsed = fastURI.parse(uri)
100
+ t.equal(reparsed.query, 'key=value%23still-query', 'hash remains query data')
101
+ t.equal(reparsed.fragment, 'first%23still-fragment', 'hash remains fragment data')
102
+ t.end()
103
+ })
104
+
105
+ test('component serializers preserve each RFC 3986 literal character set', (t) => {
106
+ const unreservedAndSubDelims = "AZaz09-._~!$&'()*+,;="
107
+ const userinfo = unreservedAndSubDelims + ':'
108
+ const queryOrFragment = unreservedAndSubDelims + ':@/?'
109
+
110
+ t.equal(
111
+ fastURI.serialize({ userinfo, host: 'example.test' }),
112
+ '//' + userinfo + '@example.test',
113
+ 'userinfo literals are preserved'
114
+ )
115
+ t.equal(
116
+ fastURI.serialize({ query: queryOrFragment }),
117
+ '?' + queryOrFragment,
118
+ 'query literals are preserved'
119
+ )
120
+ t.equal(
121
+ fastURI.serialize({ fragment: queryOrFragment }),
122
+ '#' + queryOrFragment,
123
+ 'fragment literals are preserved'
124
+ )
125
+ t.end()
126
+ })
127
+
128
+ test('component serializers preserve escapes and encode Unicode as UTF-8', (t) => {
129
+ t.equal(
130
+ fastURI.serialize({ userinfo: 'café/%2f%GG', host: 'example.test' }),
131
+ '//caf%C3%A9%2F%2F%25GG@example.test',
132
+ 'userinfo preserves valid escapes, uppercases hex, and escapes malformed percent data'
133
+ )
134
+ t.equal(
135
+ fastURI.serialize({ query: '日本/%2f#%GG' }),
136
+ '?%E6%97%A5%E6%9C%AC/%2F%23%25GG',
137
+ 'query uses UTF-8 and does not double encode valid escapes'
138
+ )
139
+ t.equal(
140
+ fastURI.serialize({ fragment: '😀/%3f#%GG' }),
141
+ '#%F0%9F%98%80/%3F%23%25GG',
142
+ 'fragment uses UTF-8 and does not double encode valid escapes'
143
+ )
144
+ t.equal(
145
+ fastURI.serialize({ query: 'Kſ' }),
146
+ '?%E2%84%AA%C5%BF',
147
+ 'Unicode characters that case-fold to ASCII are still UTF-8 encoded'
148
+ )
149
+ t.end()
150
+ })
151
+
152
+ test('parsed URI serialization remains stable', (t) => {
153
+ const input = 'x://user:pass@example.test/a%2Fb?x=a/b?c&y=%23#frag/a?b%23'
154
+ const serialized = fastURI.serialize(fastURI.parse(input))
155
+
156
+ t.equal(serialized, input, 'an already normalized parsed URI round-trips unchanged')
157
+ t.equal(
158
+ fastURI.serialize(fastURI.parse(serialized)),
159
+ serialized,
160
+ 'repeated parse and serialize cycles are stable'
161
+ )
162
+ t.end()
163
+ })
@@ -21,6 +21,36 @@ test('URI Equals', (t) => {
21
21
  t.end()
22
22
  })
23
23
 
24
+ test('URI Equals rejects malformed object input even when identical', (t) => {
25
+ const malformed = { scheme: 'http', host: 'example.com', port: 99999, path: '/x' }
26
+ t.equal(fn(malformed, malformed), false)
27
+ t.end()
28
+ })
29
+
30
+ test('URI Equals preserves case-sensitive components', (t) => {
31
+ const suite = [
32
+ { pair: ['http://example.com/Admin', 'http://example.com/admin'], result: false },
33
+ { pair: ['http://example.com/?token=SECRET', 'http://example.com/?token=secret'], result: false },
34
+ { pair: ['http://example.com/#Section', 'http://example.com/#section'], result: false },
35
+ { pair: ['http://User@example.com/', 'http://user@example.com/'], result: false },
36
+ { pair: ['urn:foo:CaseSensitive', 'urn:foo:casesensitive'], result: false },
37
+ { pair: ['ws://example.com/Chat', 'ws://example.com/chat'], result: false },
38
+ { pair: ['ws://example.com/?token=SECRET', 'ws://example.com/?token=secret'], result: false },
39
+ { pair: [{ scheme: 'http', host: 'example.com', path: '/Admin' }, { scheme: 'http', host: 'example.com', path: '/admin' }], result: false }
40
+ ]
41
+ runTest(t, suite)
42
+ t.end()
43
+ })
44
+
45
+ test('URI Equals folds normalized scheme and host case', (t) => {
46
+ const suite = [
47
+ { pair: ['HTTP://EXAMPLE.COM/resource', 'http://example.com/resource'], result: true },
48
+ { pair: [{ scheme: 'HTTP', host: 'EXAMPLE.COM', path: '/resource' }, { scheme: 'http', host: 'example.com', path: '/resource' }], result: true }
49
+ ]
50
+ runTest(t, suite)
51
+ t.end()
52
+ })
53
+
24
54
  // test('IRI Equals', (t) => {
25
55
  // // example from RFC 3987
26
56
  // t.equal(URI.equal('example://a/b/c/%7Bfoo%7D/ros\xE9', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d/ros%C3%A9', IRI_OPTION), true)
@@ -66,9 +96,7 @@ test('URN Equals', (t) => {
66
96
 
67
97
  runTest(t, suite)
68
98
 
69
- t.throws(() => {
70
- fn('urn:', 'urn:FOO:a123,456')
71
- }, 'URN without nid cannot be serialized')
99
+ t.equal(fn('urn:', 'urn:FOO:a123,456'), false, 'malformed URN fails equality safely')
72
100
 
73
101
  t.end()
74
102
  })
@@ -53,6 +53,7 @@
53
53
  "host": "[2001:dbz::1]",
54
54
  "port": 80,
55
55
  "path": "",
56
+ "error": "URI host is malformed.",
56
57
  "reference": "relative"
57
58
  }
58
59
  ],
@@ -242,6 +243,7 @@
242
243
  {
243
244
  "host": "[2606:2800:220:1:248:1893:25c8:1946:43209]",
244
245
  "path": "",
246
+ "error": "URI host is malformed.",
245
247
  "reference": "relative"
246
248
  }
247
249
  ],
@@ -0,0 +1,34 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ test('IPv6 hosts normalize to the RFC 5952 canonical form', (t) => {
7
+ const cases = [
8
+ ['http://[0:0:0:0:0:0:0:1]/', 'http://[::1]/'],
9
+ ['http://[0:0:0:0:0:0:0:0]/', 'http://[::]/'],
10
+ ['http://[2001:0db8:0000:0000:0000:0000:0000:0001]/', 'http://[2001:db8::1]/'],
11
+ ['http://[2001:0:0:0:0:0:0:1]/', 'http://[2001::1]/'],
12
+ ['http://[fe80:0:0:0:0:0:0:1]/', 'http://[fe80::1]/'],
13
+ ['http://[1:0:0:0:2:0:0:3]/', 'http://[1::2:0:0:3]/']
14
+ ]
15
+
16
+ for (const [uri, normalized] of cases) {
17
+ t.equal(fastURI.normalize(uri), normalized, `${uri} normalizes to ${normalized}`)
18
+ }
19
+ t.end()
20
+ })
21
+
22
+ test('IPv6 equal() matches the same address across compressed and expanded forms', (t) => {
23
+ const pairs = [
24
+ ['http://[::1]/', 'http://[0:0:0:0:0:0:0:1]/'],
25
+ ['http://[::]/', 'http://[0:0:0:0:0:0:0:0]/'],
26
+ ['http://[2001:db8::1]/', 'http://[2001:0db8:0000:0000:0000:0000:0000:0001]/'],
27
+ ['http://[1::2:0:0:3]/', 'http://[1:0:0:0:2:0:0:3]/']
28
+ ]
29
+
30
+ for (const [a, b] of pairs) {
31
+ t.equal(fastURI.equal(a, b), true, `${a} equals ${b}`)
32
+ }
33
+ t.end()
34
+ })
@@ -0,0 +1,124 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ const HOST_ERROR = 'URI host is malformed.'
7
+
8
+ const malformedLiterals = [
9
+ '::not-valid',
10
+ 'fc00::not-hex',
11
+ 'fe80::not-hex',
12
+ '1:2:3',
13
+ '1:2:3:4:5:6:7',
14
+ '1:2:3:4:5:6:7:8:9',
15
+ '1::2::3',
16
+ '1:::2',
17
+ ':::1',
18
+ '12345::',
19
+ '1:2:3:4:5:6:7::8',
20
+ '::ffff:192.0.2.999',
21
+ '::ffff:192.0.2',
22
+ '::ffff:192.168.001.1',
23
+ '::192.0.2.1:1',
24
+ '1:2:3:4:5:192.0.2.1::',
25
+ 'v.foo',
26
+ 'v1.',
27
+ 'v1.foo%25bar',
28
+ 'v1.K',
29
+ 'fe80::1%25',
30
+ 'fe80::1%25eth 0',
31
+ 'fe80::1%25eth%ZZ',
32
+ 'fe80::1%25K',
33
+ 'not-an-ip'
34
+ ]
35
+
36
+ test('malformed bracketed IP literals fail without being rewritten', (t) => {
37
+ for (const literal of malformedLiterals) {
38
+ const uri = `http://[${literal}]/private`
39
+ const parsed = fastURI.parse(uri)
40
+
41
+ t.equal(parsed.error, HOST_ERROR, `parse rejects ${literal}`)
42
+ t.equal(parsed.host, `[${literal.toLowerCase()}]`, `parse does not truncate ${literal}`)
43
+ t.equal(fastURI.normalize(uri), uri, `normalize preserves ${literal}`)
44
+ t.equal(fastURI.equal(uri, uri), false, `equal rejects ${literal}`)
45
+ }
46
+ t.end()
47
+ })
48
+
49
+ test('resolve throws for malformed bracketed IP literals', (t) => {
50
+ for (const literal of malformedLiterals) {
51
+ const uri = `http://[${literal}]/private`
52
+
53
+ t.throws(
54
+ () => fastURI.resolve(uri, 'child'),
55
+ /URI host is malformed\./,
56
+ `rejects malformed base ${literal}`
57
+ )
58
+ t.throws(
59
+ () => fastURI.resolve('http://example.com/', uri),
60
+ /URI host is malformed\./,
61
+ `rejects malformed relative input ${literal}`
62
+ )
63
+ }
64
+ t.end()
65
+ })
66
+
67
+ test('valid IPv6, IPvFuture, embedded IPv4, and zone forms normalize safely', (t) => {
68
+ const cases = [
69
+ ['http://[::]/', 'http://[::]/', '::'],
70
+ ['http://[::1]/', 'http://[::1]/', '::1'],
71
+ ['http://[1::]/', 'http://[1::]/', '1::'],
72
+ ['http://[2001:0DB8::0001]/', 'http://[2001:db8::1]/', '2001:db8::1'],
73
+ ['http://[0:0:0:0:0:0:0:0]/', 'http://[::]/', '::'],
74
+ ['http://[::ffff:192.0.2.1]/', 'http://[::ffff:192.0.2.1]/', '::ffff:192.0.2.1'],
75
+ ['http://[1:2:3:4:5:6:192.0.2.1]/', 'http://[1:2:3:4:5:6:192.0.2.1]/', '1:2:3:4:5:6:192.0.2.1'],
76
+ ['http://[fe80::A%25EN1]/', 'http://[fe80::a%25EN1]/', 'fe80::a%EN1'],
77
+ ['http://[fe80::a%en1]/', 'http://[fe80::a%25en1]/', 'fe80::a%en1'],
78
+ ['http://[fe80::a%25eth%2D0]/', 'http://[fe80::a%25eth%2D0]/', 'fe80::a%eth%2D0'],
79
+ ['http://[v1.example]/', 'http://[v1.example]/', '[v1.example]'],
80
+ ['http://[vF.A:b]/', 'http://[vf.a:b]/', '[vf.a:b]']
81
+ ]
82
+
83
+ for (const [uri, normalized, host] of cases) {
84
+ const parsed = fastURI.parse(uri)
85
+ t.equal(parsed.error, undefined, `${uri} parses without error`)
86
+ t.equal(parsed.host, host, `${uri} has the expected host`)
87
+ t.equal(fastURI.normalize(uri), normalized, `${uri} normalizes safely`)
88
+ }
89
+ t.end()
90
+ })
91
+
92
+ test('hosts with unbalanced or misplaced IP-literal brackets are rejected', (t) => {
93
+ const malformed = [
94
+ 'http://[fe80',
95
+ 'http://[',
96
+ 'http://[not-an-ip',
97
+ 'http://[\u65e5\u672c',
98
+ 'http://user@[@127.0.0.1:8123/admin',
99
+ 'http://user@]127.0.0.1:8123/admin',
100
+ 'http://user@prefix[@127.0.0.1:8123/admin',
101
+ 'http://user@prefix]@127.0.0.1:8123/admin'
102
+ ]
103
+ const modes = [
104
+ ['default', undefined],
105
+ ['Unicode', { unicodeSupport: true }]
106
+ ]
107
+
108
+ for (const [mode, options] of modes) {
109
+ for (const uri of malformed) {
110
+ const parsed = fastURI.parse(uri, options)
111
+ const message = `${mode} mode rejects ${uri}`
112
+
113
+ t.equal(parsed.error, HOST_ERROR, `parse ${message}`)
114
+ t.equal(fastURI.normalize(uri, options), uri, `normalize preserves ${uri} in ${mode} mode`)
115
+ t.equal(fastURI.equal(uri, uri, options), false, `equal ${message}`)
116
+ t.throws(
117
+ () => fastURI.resolve('http://example.com/', uri, options),
118
+ /URI host is malformed\./,
119
+ `resolve ${message}`
120
+ )
121
+ }
122
+ }
123
+ t.end()
124
+ })
@@ -0,0 +1,77 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ const MALFORMED_PERCENT_ERROR = 'URI contains malformed percent-encoding.'
7
+
8
+ const malformedComponents = [
9
+ ['path', 'x://example.test/a%'],
10
+ ['path with one trailing hex digit', 'x://example.test/a%2'],
11
+ ['path with non-hex digits', 'x://example.test/a%GG'],
12
+ ['host', 'x://exa%mple.test/path'],
13
+ ['userinfo', 'x://us%er@example.test/path'],
14
+ ['query', 'x://example.test/path?q=%G0'],
15
+ ['fragment', 'x://example.test/path#frag%1']
16
+ ]
17
+
18
+ test('parse reports malformed percent syntax in generic URI components', (t) => {
19
+ for (const [component, uri] of malformedComponents) {
20
+ t.equal(fastURI.parse(uri).error, MALFORMED_PERCENT_ERROR, component)
21
+ }
22
+ t.end()
23
+ })
24
+
25
+ test('normalize preserves malformed percent input unchanged', (t) => {
26
+ for (const [component, uri] of malformedComponents) {
27
+ t.equal(fastURI.normalize(uri), uri, component)
28
+ }
29
+ t.end()
30
+ })
31
+
32
+ test('equal does not equate malformed input with repaired valid input', (t) => {
33
+ const cases = [
34
+ ['x://example.test/a%', 'x://example.test/a%25'],
35
+ ['x://exa%mple.test/path', 'x://exa%25mple.test/path'],
36
+ ['x://us%er@example.test/path', 'x://us%25er@example.test/path'],
37
+ ['x://example.test/path?q=%', 'x://example.test/path?q=%25'],
38
+ ['x://example.test/path#%', 'x://example.test/path#%25']
39
+ ]
40
+
41
+ for (const [malformed, repaired] of cases) {
42
+ t.equal(fastURI.equal(malformed, repaired, {}), false, malformed)
43
+ }
44
+ t.end()
45
+ })
46
+
47
+ test('resolve rejects malformed percent syntax in either input', (t) => {
48
+ t.throws(
49
+ () => fastURI.resolve('x://example.test/base%', 'child'),
50
+ /URI contains malformed percent-encoding\./,
51
+ 'malformed base'
52
+ )
53
+ t.throws(
54
+ () => fastURI.resolve('x://example.test/base', 'child%'),
55
+ /URI contains malformed percent-encoding\./,
56
+ 'malformed relative reference'
57
+ )
58
+ t.end()
59
+ })
60
+
61
+ test('valid percent octets remain valid without UTF-8 validation', (t) => {
62
+ const uri = '/%ff?q=%80#%fe'
63
+ const parsed = fastURI.parse(uri)
64
+
65
+ t.equal(parsed.error, undefined, 'non-UTF-8 octets are valid percent syntax')
66
+ t.equal(parsed.path, '/%FF', 'path octet is preserved and hex is uppercased')
67
+ t.equal(parsed.query, 'q=%80', 'query octet is preserved')
68
+ t.equal(parsed.fragment, '%FE', 'fragment octet is preserved and hex is uppercased')
69
+ t.equal(fastURI.normalize(uri), '/%FF?q=%80#%FE', 'normalization preserves the octets')
70
+
71
+ const allGenericComponents = fastURI.parse('x://u%2f@exa%2fmple.test/%2f?q=%2f#%2f')
72
+ t.equal(allGenericComponents.error, undefined, 'valid escapes are accepted in every generic component')
73
+
74
+ const ipv6Zone = fastURI.parse('//[2001:db8::7%en0]')
75
+ t.equal(ipv6Zone.error, undefined, 'historically accepted raw IPv6 zone separator is unchanged')
76
+ t.end()
77
+ })
@@ -0,0 +1,61 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ const malformedURNs = [
7
+ 'urn:',
8
+ 'URN:',
9
+ 'urn:foo',
10
+ 'urn::foo',
11
+ 'urn:foo:',
12
+ 'urn:%66oo:bar'
13
+ ]
14
+
15
+ test('parse reports malformed ordinary URNs', (t) => {
16
+ for (const uri of malformedURNs) {
17
+ t.match(fastURI.parse(uri).error, /^URN can not be parsed\.?$/, uri)
18
+ }
19
+ t.end()
20
+ })
21
+
22
+ test('normalize preserves malformed ordinary URNs without throwing', (t) => {
23
+ for (const uri of malformedURNs) {
24
+ t.doesNotThrow(() => fastURI.normalize(uri), `${uri} does not throw`)
25
+ t.equal(fastURI.normalize(uri), uri, `${uri} is preserved`)
26
+ }
27
+ t.equal(
28
+ fastURI.normalize('urn:foo', { reference: 'relative' }),
29
+ 'urn:foo',
30
+ 'an earlier parse error does not hide the missing URN nid'
31
+ )
32
+ t.end()
33
+ })
34
+
35
+ test('equal returns false for malformed ordinary URNs', (t) => {
36
+ for (const uri of malformedURNs) {
37
+ t.equal(fastURI.equal(uri, uri, {}), false, `${uri} is not equal to itself as malformed input`)
38
+ t.equal(fastURI.equal(uri, 'urn:foo:bar', {}), false, `${uri} is not equal to a valid URN`)
39
+ }
40
+ t.end()
41
+ })
42
+
43
+ test('resolve handles malformed ordinary URNs without throwing', (t) => {
44
+ for (const uri of malformedURNs) {
45
+ t.doesNotThrow(() => fastURI.resolve('uri://base/', uri), `${uri} does not throw as a relative reference`)
46
+ t.doesNotThrow(() => fastURI.resolve(uri, ''), `${uri} does not throw as a base URI`)
47
+ }
48
+ // resolve preserves the malformed scheme-specific input rather than surfacing
49
+ // an uncaught 'URN without nid cannot be serialized' error (matches upstream uri-js)
50
+ t.equal(fastURI.resolve('uri://base/', 'urn:'), 'urn:', 'malformed relative URN is preserved')
51
+ t.equal(fastURI.resolve('URN:', ''), 'urn:', 'scheme case is normalized')
52
+ t.equal(fastURI.resolve('uri://base/', 'urn:%66oo:bar'), 'urn:foo:bar', 'percent-encoding is decoded')
53
+ t.end()
54
+ })
55
+
56
+ test('valid URNs retain their existing behavior', (t) => {
57
+ t.equal(fastURI.normalize('URN:FOO:a123,456'), 'urn:foo:a123,456')
58
+ t.equal(fastURI.equal('urn:foo:a123,456', 'URN:FOO:a123,456', {}), true)
59
+ t.equal(fastURI.resolve('uri://base/', 'urn:'), 'urn:', 'default resolve behavior is unchanged')
60
+ t.end()
61
+ })
@@ -150,10 +150,12 @@ test('URI parse', (t) => {
150
150
  t.equal(components.query, undefined, 'query')
151
151
  t.equal(components.fragment, '%0D', 'fragment')
152
152
 
153
- // malformed percent-encoded fragment must not throw
153
+ // a fragment whose decoded bytes are not valid UTF-8 is still valid
154
+ // percent-encoding (RFC 3986 §2.1 is byte-level), so it is preserved as-is
155
+ // rather than being flagged as malformed
154
156
  components = fastURI.parse('http://example.com/#%E0%A4A')
155
- t.equal(components.error, 'URI malformed', 'malformed fragment errors')
156
- t.equal(components.fragment, '%E0%A4A', 'malformed fragment is preserved')
157
+ t.equal(components.error, undefined, 'valid percent-encoding is not flagged as malformed')
158
+ t.equal(components.fragment, '%E0%A4A', 'fragment is preserved')
157
159
 
158
160
  // all
159
161
  components = fastURI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
@@ -212,6 +214,7 @@ test('URI parse', (t) => {
212
214
  // invalid IPv6
213
215
  components = fastURI.parse('//[2001:dbZ::7]')
214
216
  t.equal(components.host, '[2001:dbz::7]')
217
+ t.equal(components.error, 'URI host is malformed.')
215
218
 
216
219
  // mixed IPv4address & IPv6address
217
220
  components = fastURI.parse('//[::ffff:129.144.52.38]')
@@ -316,6 +319,7 @@ test('URI parse', (t) => {
316
319
 
317
320
  components = fastURI.parse('//[2606:2800:220:1:248:1893:25c8:1946:43209]')
318
321
  t.equal(components.host, '[2606:2800:220:1:248:1893:25c8:1946:43209]')
322
+ t.equal(components.error, 'URI host is malformed.')
319
323
 
320
324
  components = fastURI.parse('urn:foo:|\\24fpl')
321
325
  t.equal(components.error, 'URN can not be parsed.')
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ const test = require('tape')
4
+ const fastURI = require('..')
5
+
6
+ test('query percent-encoding is normalized (RFC 3986 §6.2.2)', (t) => {
7
+ // hex digits are uppercased, like the path component already does
8
+ t.equal(fastURI.normalize('x://h/p?a=%2a'), 'x://h/p?a=%2A', 'uppercases hex in query')
9
+ // unreserved characters are decoded
10
+ t.equal(fastURI.normalize('x://h/p?a=%7e%2e'), 'x://h/p?a=~.', 'decodes unreserved in query')
11
+ // reserved characters stay percent-encoded
12
+ t.equal(fastURI.normalize('x://h/p?a=%2F'), 'x://h/p?a=%2F', 'keeps reserved encoded in query')
13
+ // raw characters that are not allowed are percent-encoded
14
+ t.equal(fastURI.normalize('x://h/p?a b'), 'x://h/p?a%20b', 'encodes a raw space in query')
15
+ t.equal(fastURI.normalize('x://h/p?café'), 'x://h/p?caf%C3%A9', 'encodes raw non-ASCII in query')
16
+ // `?` is allowed unencoded in a query
17
+ t.equal(fastURI.normalize('x://h/p?a?b'), 'x://h/p?a?b', 'keeps `?` raw in query')
18
+
19
+ t.end()
20
+ })
21
+
22
+ test('fragment percent-encoding is normalized without decoding reserved characters', (t) => {
23
+ // reserved characters must NOT be decoded — `%2F` is not `/`
24
+ t.equal(fastURI.normalize('x://h/p#a%2Fb%2A'), 'x://h/p#a%2Fb%2A', 'keeps reserved encoded in fragment')
25
+ // hex is uppercased and unreserved is decoded
26
+ t.equal(fastURI.normalize('x://h/p#a%2a%7e'), 'x://h/p#a%2A~', 'uppercases hex and decodes unreserved in fragment')
27
+ // raw characters are still encoded
28
+ t.equal(fastURI.normalize('x://h/p#a b'), 'x://h/p#a%20b', 'encodes a raw space in fragment')
29
+ // `?` and `/` are allowed unencoded in a fragment
30
+ t.equal(fastURI.normalize('x://h/p#f?x/y'), 'x://h/p#f?x/y', 'keeps `?` and `/` raw in fragment')
31
+
32
+ t.end()
33
+ })