@nocobase/plugin-mcp-server 2.1.0-alpha.10 → 2.1.0-alpha.9

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 (78) hide show
  1. package/build.config.ts +0 -1
  2. package/dist/client/index.js +1 -1
  3. package/dist/externalVersion.js +5 -6
  4. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/http-errors/HISTORY.md +186 -0
  5. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/http-errors/LICENSE +23 -0
  6. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/http-errors/README.md +169 -0
  7. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/http-errors/index.js +290 -0
  8. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/http-errors/package.json +54 -0
  9. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/LICENSE +21 -0
  10. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/README.md +138 -0
  11. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  12. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  13. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/index.js +23 -0
  14. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/internal.js +218 -0
  15. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  16. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  17. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
  18. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  19. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  20. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  21. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  22. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  23. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  24. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  25. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  26. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/utf16.js +187 -0
  27. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/utf32.js +307 -0
  28. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/encodings/utf7.js +283 -0
  29. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  30. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  31. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/lib/index.d.ts +129 -0
  32. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/lib/index.js +182 -0
  33. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/lib/streams.js +105 -0
  34. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/package.json +70 -0
  35. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite/types/encodings.d.ts +423 -0
  36. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/LICENSE +22 -0
  37. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/README.md +223 -0
  38. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/index.d.ts +85 -0
  39. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/index.js +336 -0
  40. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/package.json +46 -0
  41. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/HISTORY.md +87 -0
  42. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/LICENSE +23 -0
  43. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/README.md +139 -0
  44. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/codes.json +65 -0
  45. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/index.js +146 -0
  46. package/dist/node_modules/@modelcontextprotocol/sdk/node_modules/statuses/package.json +49 -0
  47. package/dist/node_modules/light-my-request/package.json +1 -1
  48. package/dist/node_modules/openapi-types/package.json +1 -1
  49. package/dist/server/mcp-server.js +3 -4
  50. package/dist/server/mcp-tools.js +0 -56
  51. package/dist/server/plugin.d.ts +1 -10
  52. package/dist/server/plugin.js +4 -116
  53. package/package.json +2 -3
  54. package/dist/node_modules/fast-uri/.gitattributes +0 -2
  55. package/dist/node_modules/fast-uri/.github/.stale.yml +0 -21
  56. package/dist/node_modules/fast-uri/.github/dependabot.yml +0 -13
  57. package/dist/node_modules/fast-uri/.github/tests_checker.yml +0 -8
  58. package/dist/node_modules/fast-uri/.github/workflows/ci.yml +0 -23
  59. package/dist/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +0 -20
  60. package/dist/node_modules/fast-uri/LICENSE +0 -30
  61. package/dist/node_modules/fast-uri/README.md +0 -125
  62. package/dist/node_modules/fast-uri/benchmark.js +0 -105
  63. package/dist/node_modules/fast-uri/index.js +0 -303
  64. package/dist/node_modules/fast-uri/lib/schemes.js +0 -188
  65. package/dist/node_modules/fast-uri/lib/scopedChars.js +0 -30
  66. package/dist/node_modules/fast-uri/lib/utils.js +0 -242
  67. package/dist/node_modules/fast-uri/package.json +0 -39
  68. package/dist/node_modules/fast-uri/test/.gitkeep +0 -0
  69. package/dist/node_modules/fast-uri/test/ajv.test.js +0 -39
  70. package/dist/node_modules/fast-uri/test/compatibility.test.js +0 -131
  71. package/dist/node_modules/fast-uri/test/equal.test.js +0 -103
  72. package/dist/node_modules/fast-uri/test/parse.test.js +0 -318
  73. package/dist/node_modules/fast-uri/test/resolve.test.js +0 -75
  74. package/dist/node_modules/fast-uri/test/serialize.test.js +0 -143
  75. package/dist/node_modules/fast-uri/test/uri-js.test.js +0 -912
  76. package/dist/node_modules/fast-uri/test/util.test.js +0 -23
  77. package/dist/node_modules/fast-uri/types/index.d.ts +0 -53
  78. package/dist/node_modules/fast-uri/types/index.test-d.ts +0 -17
@@ -1,318 +0,0 @@
1
- 'use strict'
2
-
3
- const test = require('tape')
4
- const URI = require('../')
5
-
6
- test('URI parse', (t) => {
7
- let components
8
-
9
- // scheme
10
- components = URI.parse('uri:')
11
- t.equal(components.error, undefined, 'scheme errors')
12
- t.equal(components.scheme, 'uri', 'scheme')
13
- // t.equal(components.authority, undefined, "authority");
14
- t.equal(components.userinfo, undefined, 'userinfo')
15
- t.equal(components.host, undefined, 'host')
16
- t.equal(components.port, undefined, 'port')
17
- t.equal(components.path, '', 'path')
18
- t.equal(components.query, undefined, 'query')
19
- t.equal(components.fragment, undefined, 'fragment')
20
-
21
- // userinfo
22
- components = URI.parse('//@')
23
- t.equal(components.error, undefined, 'userinfo errors')
24
- t.equal(components.scheme, undefined, 'scheme')
25
- // t.equal(components.authority, "@", "authority");
26
- t.equal(components.userinfo, '', 'userinfo')
27
- t.equal(components.host, '', 'host')
28
- t.equal(components.port, undefined, 'port')
29
- t.equal(components.path, '', 'path')
30
- t.equal(components.query, undefined, 'query')
31
- t.equal(components.fragment, undefined, 'fragment')
32
-
33
- // host
34
- components = URI.parse('//')
35
- t.equal(components.error, undefined, 'host errors')
36
- t.equal(components.scheme, undefined, 'scheme')
37
- // t.equal(components.authority, "", "authority");
38
- t.equal(components.userinfo, undefined, 'userinfo')
39
- t.equal(components.host, '', 'host')
40
- t.equal(components.port, undefined, 'port')
41
- t.equal(components.path, '', 'path')
42
- t.equal(components.query, undefined, 'query')
43
- t.equal(components.fragment, undefined, 'fragment')
44
-
45
- // port
46
- components = URI.parse('//:')
47
- t.equal(components.error, undefined, 'port errors')
48
- t.equal(components.scheme, undefined, 'scheme')
49
- // t.equal(components.authority, ":", "authority");
50
- t.equal(components.userinfo, undefined, 'userinfo')
51
- t.equal(components.host, '', 'host')
52
- t.equal(components.port, '', 'port')
53
- t.equal(components.path, '', 'path')
54
- t.equal(components.query, undefined, 'query')
55
- t.equal(components.fragment, undefined, 'fragment')
56
-
57
- // path
58
- components = URI.parse('')
59
- t.equal(components.error, undefined, 'path errors')
60
- t.equal(components.scheme, undefined, 'scheme')
61
- // t.equal(components.authority, undefined, "authority");
62
- t.equal(components.userinfo, undefined, 'userinfo')
63
- t.equal(components.host, undefined, 'host')
64
- t.equal(components.port, undefined, 'port')
65
- t.equal(components.path, '', 'path')
66
- t.equal(components.query, undefined, 'query')
67
- t.equal(components.fragment, undefined, 'fragment')
68
-
69
- // query
70
- components = URI.parse('?')
71
- t.equal(components.error, undefined, 'query errors')
72
- t.equal(components.scheme, undefined, 'scheme')
73
- // t.equal(components.authority, undefined, "authority");
74
- t.equal(components.userinfo, undefined, 'userinfo')
75
- t.equal(components.host, undefined, 'host')
76
- t.equal(components.port, undefined, 'port')
77
- t.equal(components.path, '', 'path')
78
- t.equal(components.query, '', 'query')
79
- t.equal(components.fragment, undefined, 'fragment')
80
-
81
- // fragment
82
- components = URI.parse('#')
83
- t.equal(components.error, undefined, 'fragment errors')
84
- t.equal(components.scheme, undefined, 'scheme')
85
- // t.equal(components.authority, undefined, "authority");
86
- t.equal(components.userinfo, undefined, 'userinfo')
87
- t.equal(components.host, undefined, 'host')
88
- t.equal(components.port, undefined, 'port')
89
- t.equal(components.path, '', 'path')
90
- t.equal(components.query, undefined, 'query')
91
- t.equal(components.fragment, '', 'fragment')
92
-
93
- // fragment with character tabulation
94
- components = URI.parse('#\t')
95
- t.equal(components.error, undefined, 'path errors')
96
- t.equal(components.scheme, undefined, 'scheme')
97
- // t.equal(components.authority, undefined, "authority");
98
- t.equal(components.userinfo, undefined, 'userinfo')
99
- t.equal(components.host, undefined, 'host')
100
- t.equal(components.port, undefined, 'port')
101
- t.equal(components.path, '', 'path')
102
- t.equal(components.query, undefined, 'query')
103
- t.equal(components.fragment, '%09', 'fragment')
104
-
105
- // fragment with line feed
106
- components = URI.parse('#\n')
107
- t.equal(components.error, undefined, 'path errors')
108
- t.equal(components.scheme, undefined, 'scheme')
109
- // t.equal(components.authority, undefined, "authority");
110
- t.equal(components.userinfo, undefined, 'userinfo')
111
- t.equal(components.host, undefined, 'host')
112
- t.equal(components.port, undefined, 'port')
113
- t.equal(components.path, '', 'path')
114
- t.equal(components.query, undefined, 'query')
115
- t.equal(components.fragment, '%0A', 'fragment')
116
-
117
- // fragment with line tabulation
118
- components = URI.parse('#\v')
119
- t.equal(components.error, undefined, 'path errors')
120
- t.equal(components.scheme, undefined, 'scheme')
121
- // t.equal(components.authority, undefined, "authority");
122
- t.equal(components.userinfo, undefined, 'userinfo')
123
- t.equal(components.host, undefined, 'host')
124
- t.equal(components.port, undefined, 'port')
125
- t.equal(components.path, '', 'path')
126
- t.equal(components.query, undefined, 'query')
127
- t.equal(components.fragment, '%0B', 'fragment')
128
-
129
- // fragment with form feed
130
- components = URI.parse('#\f')
131
- t.equal(components.error, undefined, 'path errors')
132
- t.equal(components.scheme, undefined, 'scheme')
133
- // t.equal(components.authority, undefined, "authority");
134
- t.equal(components.userinfo, undefined, 'userinfo')
135
- t.equal(components.host, undefined, 'host')
136
- t.equal(components.port, undefined, 'port')
137
- t.equal(components.path, '', 'path')
138
- t.equal(components.query, undefined, 'query')
139
- t.equal(components.fragment, '%0C', 'fragment')
140
-
141
- // fragment with carriage return
142
- components = URI.parse('#\r')
143
- t.equal(components.error, undefined, 'path errors')
144
- t.equal(components.scheme, undefined, 'scheme')
145
- // t.equal(components.authority, undefined, "authority");
146
- t.equal(components.userinfo, undefined, 'userinfo')
147
- t.equal(components.host, undefined, 'host')
148
- t.equal(components.port, undefined, 'port')
149
- t.equal(components.path, '', 'path')
150
- t.equal(components.query, undefined, 'query')
151
- t.equal(components.fragment, '%0D', 'fragment')
152
-
153
- // all
154
- components = URI.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
155
- t.equal(components.error, undefined, 'all errors')
156
- t.equal(components.scheme, 'uri', 'scheme')
157
- // t.equal(components.authority, "user:pass@example.com:123", "authority");
158
- t.equal(components.userinfo, 'user:pass', 'userinfo')
159
- t.equal(components.host, 'example.com', 'host')
160
- t.equal(components.port, 123, 'port')
161
- t.equal(components.path, '/one/two.three', 'path')
162
- t.equal(components.query, 'q1=a1&q2=a2', 'query')
163
- t.equal(components.fragment, 'body', 'fragment')
164
-
165
- // IPv4address
166
- components = URI.parse('//10.10.10.10')
167
- t.equal(components.error, undefined, 'IPv4address errors')
168
- t.equal(components.scheme, undefined, 'scheme')
169
- t.equal(components.userinfo, undefined, 'userinfo')
170
- t.equal(components.host, '10.10.10.10', 'host')
171
- t.equal(components.port, undefined, 'port')
172
- t.equal(components.path, '', 'path')
173
- t.equal(components.query, undefined, 'query')
174
- t.equal(components.fragment, undefined, 'fragment')
175
-
176
- // IPv4address with unformated 0 stay as-is
177
- components = URI.parse('//10.10.000.10') // not valid as per https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
178
- t.equal(components.error, undefined, 'IPv4address errors')
179
- t.equal(components.scheme, undefined, 'scheme')
180
- t.equal(components.userinfo, undefined, 'userinfo')
181
- t.equal(components.host, '10.10.000.10', 'host')
182
- t.equal(components.port, undefined, 'port')
183
- t.equal(components.path, '', 'path')
184
- t.equal(components.query, undefined, 'query')
185
- t.equal(components.fragment, undefined, 'fragment')
186
- components = URI.parse('//01.01.01.01') // not valid in URIs: https://datatracker.ietf.org/doc/html/rfc3986#section-7.4
187
- t.equal(components.error, undefined, 'IPv4address errors')
188
- t.equal(components.scheme, undefined, 'scheme')
189
- t.equal(components.userinfo, undefined, 'userinfo')
190
- t.equal(components.host, '01.01.01.01', 'host')
191
- t.equal(components.port, undefined, 'port')
192
- t.equal(components.path, '', 'path')
193
- t.equal(components.query, undefined, 'query')
194
- t.equal(components.fragment, undefined, 'fragment')
195
-
196
- // IPv6address
197
- components = URI.parse('//[2001:db8::7]')
198
- t.equal(components.error, undefined, 'IPv4address errors')
199
- t.equal(components.scheme, undefined, 'scheme')
200
- t.equal(components.userinfo, undefined, 'userinfo')
201
- t.equal(components.host, '2001:db8::7', 'host')
202
- t.equal(components.port, undefined, 'port')
203
- t.equal(components.path, '', 'path')
204
- t.equal(components.query, undefined, 'query')
205
- t.equal(components.fragment, undefined, 'fragment')
206
-
207
- // invalid IPv6
208
- components = URI.parse('//[2001:dbZ::7]')
209
- t.equal(components.host, '[2001:dbz::7]')
210
-
211
- // mixed IPv4address & IPv6address
212
- components = URI.parse('//[::ffff:129.144.52.38]')
213
- t.equal(components.error, undefined, 'IPv4address errors')
214
- t.equal(components.scheme, undefined, 'scheme')
215
- t.equal(components.userinfo, undefined, 'userinfo')
216
- t.equal(components.host, '::ffff:129.144.52.38', 'host')
217
- t.equal(components.port, undefined, 'port')
218
- t.equal(components.path, '', 'path')
219
- t.equal(components.query, undefined, 'query')
220
- t.equal(components.fragment, undefined, 'fragment')
221
-
222
- // mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
223
- components = URI.parse('uri://10.10.10.10.example.com/en/process')
224
- t.equal(components.error, undefined, 'mixed errors')
225
- t.equal(components.scheme, 'uri', 'scheme')
226
- t.equal(components.userinfo, undefined, 'userinfo')
227
- t.equal(components.host, '10.10.10.10.example.com', 'host')
228
- t.equal(components.port, undefined, 'port')
229
- t.equal(components.path, '/en/process', 'path')
230
- t.equal(components.query, undefined, 'query')
231
- t.equal(components.fragment, undefined, 'fragment')
232
-
233
- // IPv6address, example from bkw (https://github.com/garycourt/uri-js/pull/16)
234
- components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946]/test')
235
- t.equal(components.error, undefined, 'IPv6address errors')
236
- t.equal(components.scheme, undefined, 'scheme')
237
- t.equal(components.userinfo, undefined, 'userinfo')
238
- t.equal(components.host, '2606:2800:220:1:248:1893:25c8:1946', 'host')
239
- t.equal(components.port, undefined, 'port')
240
- t.equal(components.path, '/test', 'path')
241
- t.equal(components.query, undefined, 'query')
242
- t.equal(components.fragment, undefined, 'fragment')
243
-
244
- // IPv6address, example from RFC 5952
245
- components = URI.parse('//[2001:db8::1]:80')
246
- t.equal(components.error, undefined, 'IPv6address errors')
247
- t.equal(components.scheme, undefined, 'scheme')
248
- t.equal(components.userinfo, undefined, 'userinfo')
249
- t.equal(components.host, '2001:db8::1', 'host')
250
- t.equal(components.port, 80, 'port')
251
- t.equal(components.path, '', 'path')
252
- t.equal(components.query, undefined, 'query')
253
- t.equal(components.fragment, undefined, 'fragment')
254
-
255
- // IPv6address with zone identifier, RFC 6874
256
- components = URI.parse('//[fe80::a%25en1]')
257
- t.equal(components.error, undefined, 'IPv4address errors')
258
- t.equal(components.scheme, undefined, 'scheme')
259
- t.equal(components.userinfo, undefined, 'userinfo')
260
- t.equal(components.host, 'fe80::a%en1', 'host')
261
- t.equal(components.port, undefined, 'port')
262
- t.equal(components.path, '', 'path')
263
- t.equal(components.query, undefined, 'query')
264
- t.equal(components.fragment, undefined, 'fragment')
265
-
266
- // IPv6address with an unescaped interface specifier, example from pekkanikander (https://github.com/garycourt/uri-js/pull/22)
267
- components = URI.parse('//[2001:db8::7%en0]')
268
- t.equal(components.error, undefined, 'IPv6address interface errors')
269
- t.equal(components.scheme, undefined, 'scheme')
270
- t.equal(components.userinfo, undefined, 'userinfo')
271
- t.equal(components.host, '2001:db8::7%en0', 'host')
272
- t.equal(components.port, undefined, 'port')
273
- t.equal(components.path, '', 'path')
274
- t.equal(components.query, undefined, 'query')
275
- t.equal(components.fragment, undefined, 'fragment')
276
-
277
- // UUID V1
278
- components = URI.parse('urn:uuid:b571b0bc-4713-11ec-81d3-0242ac130003')
279
- t.equal(components.error, undefined, 'errors')
280
- t.equal(components.scheme, 'urn', 'scheme')
281
- // t.equal(components.authority, undefined, "authority");
282
- t.equal(components.userinfo, undefined, 'userinfo')
283
- t.equal(components.host, undefined, 'host')
284
- t.equal(components.port, undefined, 'port')
285
- t.equal(components.path, undefined, 'path')
286
- t.equal(components.query, undefined, 'query')
287
- t.equal(components.fragment, undefined, 'fragment')
288
- t.equal(components.nid, 'uuid', 'nid')
289
- t.equal(components.nss, undefined, 'nss')
290
- t.equal(components.uuid, 'b571b0bc-4713-11ec-81d3-0242ac130003', 'uuid')
291
-
292
- // UUID v4
293
- components = URI.parse('urn:uuid:97a32222-89b7-420e-8507-4360723e2c2a')
294
- t.equal(components.uuid, '97a32222-89b7-420e-8507-4360723e2c2a', 'uuid')
295
-
296
- components = URI.parse('urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
297
- t.notSame(components.error, undefined, 'errors')
298
-
299
- components = URI.parse('urn:foo:a123,456')
300
- t.equal(components.error, undefined, 'errors')
301
- t.equal(components.scheme, 'urn', 'scheme')
302
- // t.equal(components.authority, undefined, "authority");
303
- t.equal(components.userinfo, undefined, 'userinfo')
304
- t.equal(components.host, undefined, 'host')
305
- t.equal(components.port, undefined, 'port')
306
- t.equal(components.path, undefined, 'path')
307
- t.equal(components.query, undefined, 'query')
308
- t.equal(components.fragment, undefined, 'fragment')
309
- t.equal(components.nid, 'foo', 'nid')
310
- t.equal(components.nss, 'a123,456', 'nss')
311
-
312
- components = URI.parse('//[2606:2800:220:1:248:1893:25c8:1946:43209]')
313
- t.equal(components.host, '[2606:2800:220:1:248:1893:25c8:1946:43209]')
314
-
315
- components = URI.parse('urn:foo:|\\24fpl')
316
- t.equal(components.error, 'URN can not be parsed.')
317
- t.end()
318
- })
@@ -1,75 +0,0 @@
1
- 'use strict'
2
-
3
- const test = require('tape')
4
- const URI = require('../')
5
-
6
- test('URI Resolving', (t) => {
7
- // normal examples from RFC 3986
8
- const base = 'uri://a/b/c/d;p?q'
9
- t.equal(URI.resolve(base, 'g:h'), 'g:h', 'g:h')
10
- t.equal(URI.resolve(base, 'g:h'), 'g:h', 'g:h')
11
- t.equal(URI.resolve(base, 'g'), 'uri://a/b/c/g', 'g')
12
- t.equal(URI.resolve(base, './g'), 'uri://a/b/c/g', './g')
13
- t.equal(URI.resolve(base, 'g/'), 'uri://a/b/c/g/', 'g/')
14
- t.equal(URI.resolve(base, '/g'), 'uri://a/g', '/g')
15
- t.equal(URI.resolve(base, '//g'), 'uri://g', '//g')
16
- t.equal(URI.resolve(base, '?y'), 'uri://a/b/c/d;p?y', '?y')
17
- t.equal(URI.resolve(base, 'g?y'), 'uri://a/b/c/g?y', 'g?y')
18
- t.equal(URI.resolve(base, '#s'), 'uri://a/b/c/d;p?q#s', '#s')
19
- t.equal(URI.resolve(base, 'g#s'), 'uri://a/b/c/g#s', 'g#s')
20
- t.equal(URI.resolve(base, 'g?y#s'), 'uri://a/b/c/g?y#s', 'g?y#s')
21
- t.equal(URI.resolve(base, ';x'), 'uri://a/b/c/;x', ';x')
22
- t.equal(URI.resolve(base, 'g;x'), 'uri://a/b/c/g;x', 'g;x')
23
- t.equal(URI.resolve(base, 'g;x?y#s'), 'uri://a/b/c/g;x?y#s', 'g;x?y#s')
24
- t.equal(URI.resolve(base, ''), 'uri://a/b/c/d;p?q', '')
25
- t.equal(URI.resolve(base, '.'), 'uri://a/b/c/', '.')
26
- t.equal(URI.resolve(base, './'), 'uri://a/b/c/', './')
27
- t.equal(URI.resolve(base, '..'), 'uri://a/b/', '..')
28
- t.equal(URI.resolve(base, '../'), 'uri://a/b/', '../')
29
- t.equal(URI.resolve(base, '../g'), 'uri://a/b/g', '../g')
30
- t.equal(URI.resolve(base, '../..'), 'uri://a/', '../..')
31
- t.equal(URI.resolve(base, '../../'), 'uri://a/', '../../')
32
- t.equal(URI.resolve(base, '../../g'), 'uri://a/g', '../../g')
33
-
34
- // abnormal examples from RFC 3986
35
- t.equal(URI.resolve(base, '../../../g'), 'uri://a/g', '../../../g')
36
- t.equal(URI.resolve(base, '../../../../g'), 'uri://a/g', '../../../../g')
37
-
38
- t.equal(URI.resolve(base, '/./g'), 'uri://a/g', '/./g')
39
- t.equal(URI.resolve(base, '/../g'), 'uri://a/g', '/../g')
40
- t.equal(URI.resolve(base, 'g.'), 'uri://a/b/c/g.', 'g.')
41
- t.equal(URI.resolve(base, '.g'), 'uri://a/b/c/.g', '.g')
42
- t.equal(URI.resolve(base, 'g..'), 'uri://a/b/c/g..', 'g..')
43
- t.equal(URI.resolve(base, '..g'), 'uri://a/b/c/..g', '..g')
44
-
45
- t.equal(URI.resolve(base, './../g'), 'uri://a/b/g', './../g')
46
- t.equal(URI.resolve(base, './g/.'), 'uri://a/b/c/g/', './g/.')
47
- t.equal(URI.resolve(base, 'g/./h'), 'uri://a/b/c/g/h', 'g/./h')
48
- t.equal(URI.resolve(base, 'g/../h'), 'uri://a/b/c/h', 'g/../h')
49
- t.equal(URI.resolve(base, 'g;x=1/./y'), 'uri://a/b/c/g;x=1/y', 'g;x=1/./y')
50
- t.equal(URI.resolve(base, 'g;x=1/../y'), 'uri://a/b/c/y', 'g;x=1/../y')
51
-
52
- t.equal(URI.resolve(base, 'g?y/./x'), 'uri://a/b/c/g?y/./x', 'g?y/./x')
53
- t.equal(URI.resolve(base, 'g?y/../x'), 'uri://a/b/c/g?y/../x', 'g?y/../x')
54
- t.equal(URI.resolve(base, 'g#s/./x'), 'uri://a/b/c/g#s/./x', 'g#s/./x')
55
- t.equal(URI.resolve(base, 'g#s/../x'), 'uri://a/b/c/g#s/../x', 'g#s/../x')
56
-
57
- t.equal(URI.resolve(base, 'uri:g'), 'uri:g', 'uri:g')
58
- t.equal(URI.resolve(base, 'uri:g', { tolerant: true }), 'uri://a/b/c/g', 'uri:g')
59
-
60
- // examples by PAEz
61
- // example was provided to avoid infinite loop within regex
62
- // this is not the case anymore
63
- // t.equal(URI.resolve('//www.g.com/', '/adf\ngf'), '//www.g.com/adf%0Agf', '/adf\\ngf')
64
- // t.equal(URI.resolve('//www.g.com/error\n/bleh/bleh', '..'), '//www.g.com/error%0A/', '//www.g.com/error\\n/bleh/bleh')
65
- t.end()
66
- })
67
-
68
- test('URN Resolving', (t) => {
69
- // example from epoberezkin
70
- t.equal(URI.resolve('', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
71
- t.equal(URI.resolve('#', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
72
- t.equal(URI.resolve('urn:some:ip:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
73
- t.equal(URI.resolve('urn:some:other:prop', 'urn:some:ip:prop'), 'urn:some:ip:prop', 'urn:some:ip:prop')
74
- t.end()
75
- })
@@ -1,143 +0,0 @@
1
- 'use strict'
2
-
3
- const test = require('tape')
4
- const URI = require('../')
5
-
6
- test('URI Serialize', (t) => {
7
- let components = {
8
- scheme: undefined,
9
- userinfo: undefined,
10
- host: undefined,
11
- port: undefined,
12
- path: undefined,
13
- query: undefined,
14
- fragment: undefined
15
- }
16
- t.equal(URI.serialize(components), '', 'Undefined Components')
17
-
18
- components = {
19
- scheme: '',
20
- userinfo: '',
21
- host: '',
22
- port: 0,
23
- path: '',
24
- query: '',
25
- fragment: ''
26
- }
27
- t.equal(URI.serialize(components), '//@:0?#', 'Empty Components')
28
-
29
- components = {
30
- scheme: 'uri',
31
- userinfo: 'foo:bar',
32
- host: 'example.com',
33
- port: 1,
34
- path: 'path',
35
- query: 'query',
36
- fragment: 'fragment'
37
- }
38
- t.equal(URI.serialize(components), 'uri://foo:bar@example.com:1/path?query#fragment', 'All Components')
39
-
40
- components = {
41
- scheme: 'uri',
42
- host: 'example.com',
43
- port: '9000'
44
- }
45
- t.equal(URI.serialize(components), 'uri://example.com:9000', 'String port')
46
-
47
- t.equal(URI.serialize({ path: '//path' }), '/%2Fpath', 'Double slash path')
48
- t.equal(URI.serialize({ path: 'foo:bar' }), 'foo%3Abar', 'Colon path')
49
- t.equal(URI.serialize({ path: '?query' }), '%3Fquery', 'Query path')
50
-
51
- t.equal(URI.serialize({ host: '10.10.10.10' }), '//10.10.10.10', 'IPv4address')
52
-
53
- // mixed IPv4address & reg-name, example from terion-name (https://github.com/garycourt/uri-js/issues/4)
54
- t.equal(URI.serialize({ host: '10.10.10.10.example.com' }), '//10.10.10.10.example.com', 'Mixed IPv4address & reg-name')
55
-
56
- // IPv6address
57
- t.equal(URI.serialize({ host: '2001:db8::7' }), '//[2001:db8::7]', 'IPv6 Host')
58
- t.equal(URI.serialize({ host: '::ffff:129.144.52.38' }), '//[::ffff:129.144.52.38]', 'IPv6 Mixed Host')
59
- t.equal(URI.serialize({ host: '2606:2800:220:1:248:1893:25c8:1946' }), '//[2606:2800:220:1:248:1893:25c8:1946]', 'IPv6 Full Host')
60
-
61
- // IPv6address with zone identifier, RFC 6874
62
- t.equal(URI.serialize({ host: 'fe80::a%en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Unescaped Host')
63
- t.equal(URI.serialize({ host: 'fe80::a%25en1' }), '//[fe80::a%25en1]', 'IPv6 Zone Escaped Host')
64
-
65
- t.end()
66
- })
67
-
68
- test('WS serialize', (t) => {
69
- t.equal(URI.serialize({ scheme: 'ws' }), 'ws:')
70
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com' }), 'ws://example.com')
71
- t.equal(URI.serialize({ scheme: 'ws', resourceName: '/' }), 'ws:')
72
- t.equal(URI.serialize({ scheme: 'ws', resourceName: '/foo' }), 'ws:/foo')
73
- t.equal(URI.serialize({ scheme: 'ws', resourceName: '/foo?bar' }), 'ws:/foo?bar')
74
- t.equal(URI.serialize({ scheme: 'ws', secure: false }), 'ws:')
75
- t.equal(URI.serialize({ scheme: 'ws', secure: true }), 'wss:')
76
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo' }), 'ws://example.com/foo')
77
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar' }), 'ws://example.com/foo?bar')
78
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', secure: false }), 'ws://example.com')
79
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', secure: true }), 'wss://example.com')
80
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
81
- t.equal(URI.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
82
- t.end()
83
- })
84
-
85
- test('WSS serialize', (t) => {
86
- t.equal(URI.serialize({ scheme: 'wss' }), 'wss:')
87
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com' }), 'wss://example.com')
88
- t.equal(URI.serialize({ scheme: 'wss', resourceName: '/' }), 'wss:')
89
- t.equal(URI.serialize({ scheme: 'wss', resourceName: '/foo' }), 'wss:/foo')
90
- t.equal(URI.serialize({ scheme: 'wss', resourceName: '/foo?bar' }), 'wss:/foo?bar')
91
- t.equal(URI.serialize({ scheme: 'wss', secure: false }), 'ws:')
92
- t.equal(URI.serialize({ scheme: 'wss', secure: true }), 'wss:')
93
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo' }), 'wss://example.com/foo')
94
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar' }), 'wss://example.com/foo?bar')
95
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', secure: false }), 'ws://example.com')
96
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', secure: true }), 'wss://example.com')
97
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: false }), 'ws://example.com/foo?bar')
98
- t.equal(URI.serialize({ scheme: 'wss', host: 'example.com', resourceName: '/foo?bar', secure: true }), 'wss://example.com/foo?bar')
99
-
100
- t.end()
101
- })
102
-
103
- test('URN serialize', (t) => {
104
- // example from RFC 2141
105
- const components = {
106
- scheme: 'urn',
107
- nid: 'foo',
108
- nss: 'a123,456'
109
- }
110
- t.equal(URI.serialize(components), 'urn:foo:a123,456')
111
- // example from RFC 4122
112
- let uuidcomponents = {
113
- scheme: 'urn',
114
- nid: 'uuid',
115
- uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
116
- }
117
- t.equal(URI.serialize(uuidcomponents), 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
118
-
119
- uuidcomponents = {
120
- scheme: 'urn',
121
- nid: 'uuid',
122
- uuid: 'notauuid-7dec-11d0-a765-00a0c91e6bf6'
123
- }
124
- t.equal(URI.serialize(uuidcomponents), 'urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6')
125
- t.end()
126
- })
127
- test('URN NID Override', (t) => {
128
- let components = URI.parse('urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6', { nid: 'uuid' })
129
- t.equal(components.error, undefined, 'errors')
130
- t.equal(components.scheme, 'urn', 'scheme')
131
- t.equal(components.path, undefined, 'path')
132
- t.equal(components.nid, 'foo', 'nid')
133
- t.equal(components.nss, undefined, 'nss')
134
- t.equal(components.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'uuid')
135
-
136
- components = {
137
- scheme: 'urn',
138
- nid: 'foo',
139
- uuid: 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
140
- }
141
- t.equal(URI.serialize(components, { nid: 'uuid' }), 'urn:foo:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
142
- t.end()
143
- })