punycode-esm 1.0.6 → 1.0.7
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/.c8rc.json +46 -0
- package/.eslintcache/punycode-esm +1 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +1 -1
- package/README.md +9 -9
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/index.html +116 -0
- package/coverage/src/lib/errors.ts.html +181 -0
- package/coverage/src/lib/index.html +116 -0
- package/coverage/src/punycode.ts.html +1198 -0
- package/coverage/tmp/coverage-93665-1722809762068-0.json +1 -0
- package/coverage/tmp/coverage-93670-1722809761911-0.json +1 -0
- package/dist/lib/errors.d.ts +4 -3
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +4 -9
- package/dist/lib/errors.js.map +1 -0
- package/dist/punycode.d.ts +14 -13
- package/dist/punycode.d.ts.map +1 -0
- package/dist/punycode.js +46 -185
- package/dist/punycode.js.map +1 -0
- package/dist/tests/unit/lib/errors.spec.d.ts +2 -0
- package/dist/tests/unit/lib/errors.spec.d.ts.map +1 -0
- package/dist/tests/unit/lib/errors.spec.js +43 -0
- package/dist/tests/unit/lib/errors.spec.js.map +1 -0
- package/dist/tests/unit/punycode.spec.d.ts +2 -0
- package/dist/tests/unit/punycode.spec.d.ts.map +1 -0
- package/dist/tests/unit/punycode.spec.js +331 -0
- package/dist/tests/unit/punycode.spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +4 -0
- package/package.json +21 -21
- package/project.json +27 -0
- package/src/lib/errors.ts +32 -0
- package/src/punycode.ts +371 -0
- package/src/tests/unit/lib/errors.spec.ts +44 -0
- package/src/tests/unit/punycode.spec.ts +343 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { suite, test } from 'mocha-chain';
|
|
3
|
+
import * as Punycode from 'punycode-esm';
|
|
4
|
+
const testData = {
|
|
5
|
+
strings: {
|
|
6
|
+
'a single basic code point': {
|
|
7
|
+
decoded: 'Bach',
|
|
8
|
+
encoded: 'Bach-'
|
|
9
|
+
},
|
|
10
|
+
'a single non-ASCII character': {
|
|
11
|
+
decoded: '\u00FC',
|
|
12
|
+
encoded: 'tda'
|
|
13
|
+
},
|
|
14
|
+
'multiple non-ASCII characters': {
|
|
15
|
+
decoded: '\u00FC\u00EB\u00E4\u00F6\u2665',
|
|
16
|
+
encoded: '4can8av2009b'
|
|
17
|
+
},
|
|
18
|
+
'mix of ASCII and non-ASCII characters': {
|
|
19
|
+
decoded: 'b\u00FCcher',
|
|
20
|
+
encoded: 'bcher-kva'
|
|
21
|
+
},
|
|
22
|
+
'long string with both ASCII and non-ASCII characters': {
|
|
23
|
+
decoded: 'Willst du die Bl\u00FCthe des fr\u00FChen, die Fr\u00FCchte des sp\u00E4teren Jahres',
|
|
24
|
+
encoded: 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'
|
|
25
|
+
},
|
|
26
|
+
'Arabic (Egyptian)': {
|
|
27
|
+
decoded: '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F',
|
|
28
|
+
encoded: 'egbpdaj6bu4bxfgehfvwxn'
|
|
29
|
+
},
|
|
30
|
+
'Chinese (simplified)': {
|
|
31
|
+
decoded: '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587',
|
|
32
|
+
encoded: 'ihqwcrb4cv8a8dqg056pqjye'
|
|
33
|
+
},
|
|
34
|
+
'Chinese (traditional)': {
|
|
35
|
+
decoded: '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587',
|
|
36
|
+
encoded: 'ihqwctvzc91f659drss3x8bo0yb'
|
|
37
|
+
},
|
|
38
|
+
Czech: {
|
|
39
|
+
decoded: 'Pro\u010Dprost\u011Bnemluv\u00ED\u010Desky',
|
|
40
|
+
encoded: 'Proprostnemluvesky-uyb24dma41a'
|
|
41
|
+
},
|
|
42
|
+
Hebrew: {
|
|
43
|
+
decoded: '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA',
|
|
44
|
+
encoded: '4dbcagdahymbxekheh6e0a7fei0b'
|
|
45
|
+
},
|
|
46
|
+
'Hindi (Devanagari)': {
|
|
47
|
+
decoded: '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902',
|
|
48
|
+
encoded: 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'
|
|
49
|
+
},
|
|
50
|
+
'Japanese (kanji and hiragana)': {
|
|
51
|
+
decoded: '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B',
|
|
52
|
+
encoded: 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'
|
|
53
|
+
},
|
|
54
|
+
'Korean (Hangul syllables)': {
|
|
55
|
+
decoded: '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C',
|
|
56
|
+
encoded: '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c'
|
|
57
|
+
},
|
|
58
|
+
'Russian (Cyrillic)': {
|
|
59
|
+
decoded: '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A\u0438',
|
|
60
|
+
encoded: 'b1abfaaepdrnnbgefbadotcwatmq2g4l'
|
|
61
|
+
},
|
|
62
|
+
Spanish: {
|
|
63
|
+
decoded: 'Porqu\u00E9nopuedensimplementehablarenEspa\u00F1ol',
|
|
64
|
+
encoded: 'PorqunopuedensimplementehablarenEspaol-fmd56a'
|
|
65
|
+
},
|
|
66
|
+
Vietnamese: {
|
|
67
|
+
decoded: 'T\u1EA1isaoh\u1ECDkh\u00F4ngth\u1EC3ch\u1EC9n\u00F3iti\u1EBFngVi\u1EC7t',
|
|
68
|
+
encoded: 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'
|
|
69
|
+
},
|
|
70
|
+
'3B-ww4c5e180e575a65lsy2b': {
|
|
71
|
+
decoded: '3\u5E74B\u7D44\u91D1\u516B\u5148\u751F',
|
|
72
|
+
encoded: '3B-ww4c5e180e575a65lsy2b'
|
|
73
|
+
},
|
|
74
|
+
'-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n': {
|
|
75
|
+
decoded: '\u5B89\u5BA4\u5948\u7F8E\u6075-with-SUPER-MONKEYS',
|
|
76
|
+
encoded: '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'
|
|
77
|
+
},
|
|
78
|
+
'Hello-Another-Way--fc4qua05auwb3674vfr0b': {
|
|
79
|
+
decoded: 'Hello-Another-Way-\u305D\u308C\u305E\u308C\u306E\u5834\u6240',
|
|
80
|
+
encoded: 'Hello-Another-Way--fc4qua05auwb3674vfr0b'
|
|
81
|
+
},
|
|
82
|
+
'2-u9tlzr9756bt3uc0v': {
|
|
83
|
+
decoded: '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B2',
|
|
84
|
+
encoded: '2-u9tlzr9756bt3uc0v'
|
|
85
|
+
},
|
|
86
|
+
'MajiKoi5-783gue6qz075azm5e': {
|
|
87
|
+
decoded: 'Maji\u3067Koi\u3059\u308B5\u79D2\u524D',
|
|
88
|
+
encoded: 'MajiKoi5-783gue6qz075azm5e'
|
|
89
|
+
},
|
|
90
|
+
'de-jg4avhby1noc0d': {
|
|
91
|
+
decoded: '\u30D1\u30D5\u30A3\u30FCde\u30EB\u30F3\u30D0',
|
|
92
|
+
encoded: 'de-jg4avhby1noc0d'
|
|
93
|
+
},
|
|
94
|
+
d9juau41awczczp: {
|
|
95
|
+
decoded: '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067',
|
|
96
|
+
encoded: 'd9juau41awczczp'
|
|
97
|
+
},
|
|
98
|
+
'ASCII string that breaks the existing rules for host-name labels': {
|
|
99
|
+
decoded: '-> $1.00 <-',
|
|
100
|
+
encoded: '-> $1.00 <--'
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
ucs2: {
|
|
104
|
+
'Consecutive astral symbols': {
|
|
105
|
+
decoded: [
|
|
106
|
+
127829,
|
|
107
|
+
119808,
|
|
108
|
+
119558,
|
|
109
|
+
119638
|
|
110
|
+
],
|
|
111
|
+
encoded: '\uD83C\uDF55\uD835\uDC00\uD834\uDF06\uD834\uDF56'
|
|
112
|
+
},
|
|
113
|
+
'U+D800 (high surrogate) followed by non-surrogates': {
|
|
114
|
+
decoded: [
|
|
115
|
+
55296,
|
|
116
|
+
97,
|
|
117
|
+
98
|
|
118
|
+
],
|
|
119
|
+
encoded: '\uD800ab'
|
|
120
|
+
},
|
|
121
|
+
'U+DC00 (low surrogate) followed by non-surrogates': {
|
|
122
|
+
decoded: [
|
|
123
|
+
56320,
|
|
124
|
+
97,
|
|
125
|
+
98
|
|
126
|
+
],
|
|
127
|
+
encoded: '\uDC00ab'
|
|
128
|
+
},
|
|
129
|
+
'High surrogate followed by another high surrogate': {
|
|
130
|
+
decoded: [
|
|
131
|
+
0xd800,
|
|
132
|
+
0xd800
|
|
133
|
+
],
|
|
134
|
+
encoded: '\uD800\uD800'
|
|
135
|
+
},
|
|
136
|
+
'Unmatched high surrogate, followed by a surrogate pair, followed by an unmatched high surrogate': {
|
|
137
|
+
decoded: [
|
|
138
|
+
0xd800,
|
|
139
|
+
0x1d306,
|
|
140
|
+
0xd800
|
|
141
|
+
],
|
|
142
|
+
encoded: '\uD800\uD834\uDF06\uD800'
|
|
143
|
+
},
|
|
144
|
+
'Low surrogate followed by another low surrogate': {
|
|
145
|
+
decoded: [
|
|
146
|
+
0xdc00,
|
|
147
|
+
0xdc00
|
|
148
|
+
],
|
|
149
|
+
encoded: '\uDC00\uDC00'
|
|
150
|
+
},
|
|
151
|
+
'Unmatched low surrogate, followed by a surrogate pair, followed by an unmatched low surrogate': {
|
|
152
|
+
decoded: [
|
|
153
|
+
0xdc00,
|
|
154
|
+
0x1d306,
|
|
155
|
+
0xdc00
|
|
156
|
+
],
|
|
157
|
+
encoded: '\uDC00\uD834\uDF06\uDC00'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
domains: {
|
|
161
|
+
'xn--maana-pta.com': {
|
|
162
|
+
decoded: 'ma\u00F1ana.com',
|
|
163
|
+
encoded: 'xn--maana-pta.com'
|
|
164
|
+
},
|
|
165
|
+
'example.com.': {
|
|
166
|
+
decoded: 'example.com.',
|
|
167
|
+
encoded: 'example.com.'
|
|
168
|
+
},
|
|
169
|
+
'xn--bcher-kva.com': {
|
|
170
|
+
decoded: 'b\u00FCcher.com',
|
|
171
|
+
encoded: 'xn--bcher-kva.com'
|
|
172
|
+
},
|
|
173
|
+
'xn--caf-dma.com': {
|
|
174
|
+
decoded: 'caf\u00E9.com',
|
|
175
|
+
encoded: 'xn--caf-dma.com'
|
|
176
|
+
},
|
|
177
|
+
'xn----dqo34k.com': {
|
|
178
|
+
decoded: '\u2603-\u2318.com',
|
|
179
|
+
encoded: 'xn----dqo34k.com'
|
|
180
|
+
},
|
|
181
|
+
'xn----dqo34kn65z.com': {
|
|
182
|
+
decoded: '\uD400\u2603-\u2318.com',
|
|
183
|
+
encoded: 'xn----dqo34kn65z.com'
|
|
184
|
+
},
|
|
185
|
+
emoji: {
|
|
186
|
+
decoded: '\uD83D\uDCA9.la',
|
|
187
|
+
encoded: 'xn--ls8h.la'
|
|
188
|
+
},
|
|
189
|
+
'Non-printable ASCII': {
|
|
190
|
+
decoded: '\0\u0001\u0002foo.bar',
|
|
191
|
+
encoded: '\0\u0001\u0002foo.bar'
|
|
192
|
+
},
|
|
193
|
+
'Email address': {
|
|
194
|
+
decoded: '\u0434\u0436\u0443\u043C\u043B\u0430@\u0434\u0436p\u0443\u043C\u043B\u0430\u0442\u0435\u0441\u0442.b\u0440\u0444a',
|
|
195
|
+
encoded: '\u0434\u0436\u0443\u043C\u043B\u0430@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq'
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
separators: {
|
|
199
|
+
'Using U+002E as separator': {
|
|
200
|
+
decoded: 'ma\u00F1ana\u002Ecom',
|
|
201
|
+
encoded: 'xn--maana-pta.com'
|
|
202
|
+
},
|
|
203
|
+
'Using U+3002 as separator': {
|
|
204
|
+
decoded: 'ma\u00F1ana\u3002com',
|
|
205
|
+
encoded: 'xn--maana-pta.com'
|
|
206
|
+
},
|
|
207
|
+
'Using U+FF0E as separator': {
|
|
208
|
+
decoded: 'ma\u00F1ana\uFF0Ecom',
|
|
209
|
+
encoded: 'xn--maana-pta.com'
|
|
210
|
+
},
|
|
211
|
+
'Using U+FF61 as separator': {
|
|
212
|
+
decoded: 'ma\u00F1ana\uFF61com',
|
|
213
|
+
encoded: 'xn--maana-pta.com'
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
suite('punycode', ()=>{
|
|
218
|
+
suite('ucs2Decode', ()=>{
|
|
219
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.ucs2)){
|
|
220
|
+
suite(description, ()=>{
|
|
221
|
+
test('success', ()=>{
|
|
222
|
+
expect(Punycode.ucs2Decode(encoded)).to.deep.equal(decoded);
|
|
223
|
+
});
|
|
224
|
+
test('idempotent', ()=>{
|
|
225
|
+
expect(Punycode.ucs2Decode(String.fromCodePoint(...decoded))).to.deep.equal(decoded);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
suite('ucs2Encode', ()=>{
|
|
231
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.ucs2)){
|
|
232
|
+
suite(description, ()=>{
|
|
233
|
+
test('success', ()=>{
|
|
234
|
+
expect(Punycode.ucs2Encode(decoded)).to.equal(encoded);
|
|
235
|
+
});
|
|
236
|
+
test('idempotent', ()=>{
|
|
237
|
+
expect(Punycode.ucs2Encode([
|
|
238
|
+
...encoded
|
|
239
|
+
].map((txt)=>txt.codePointAt(0)))).to.equal(encoded);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
test('Does not mutate argument array', ()=>{
|
|
244
|
+
const codePoints = [
|
|
245
|
+
0x61,
|
|
246
|
+
0x62,
|
|
247
|
+
0x63
|
|
248
|
+
];
|
|
249
|
+
expect(Punycode.ucs2Encode(codePoints)).to.equal('abc');
|
|
250
|
+
expect(codePoints).to.deep.equal([
|
|
251
|
+
0x61,
|
|
252
|
+
0x62,
|
|
253
|
+
0x63
|
|
254
|
+
]);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
suite('decode', ()=>{
|
|
258
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.strings)){
|
|
259
|
+
test(description, ()=>{
|
|
260
|
+
expect(Punycode.decode(encoded)).to.equal(decoded);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
test('Handles uppercase Z', ()=>{
|
|
264
|
+
expect(Punycode.decode('ZZZ')).to.equal('\u7BA5');
|
|
265
|
+
});
|
|
266
|
+
test('Throws RangeError: Illegal input >= 0x80 (not a basic code point)', ()=>{
|
|
267
|
+
expect(()=>Punycode.decode('\u0081-')).to.throw(RangeError);
|
|
268
|
+
});
|
|
269
|
+
test('Throws RangeError: Overflow: input needs wider integers to process', ()=>{
|
|
270
|
+
expect(()=>Punycode.decode('\u0081')).to.throw(RangeError);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
suite('encode', ()=>{
|
|
274
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.strings)){
|
|
275
|
+
test(description, ()=>{
|
|
276
|
+
expect(Punycode.encode(decoded)).to.equal(encoded);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
suite('toUnicode', ()=>{
|
|
281
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.domains)){
|
|
282
|
+
suite(description, ()=>{
|
|
283
|
+
test('success', ()=>{
|
|
284
|
+
expect(Punycode.toUnicode(encoded)).to.equal(decoded);
|
|
285
|
+
});
|
|
286
|
+
test('idempotent', ()=>{
|
|
287
|
+
expect(Punycode.toUnicode(decoded)).to.equal(decoded);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
suite("Does not convert names (or other strings) that don't start with `xn--`", ()=>{
|
|
292
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.strings)){
|
|
293
|
+
suite(description, ()=>{
|
|
294
|
+
test('decoded', ()=>{
|
|
295
|
+
expect(Punycode.toUnicode(decoded)).to.equal(decoded);
|
|
296
|
+
});
|
|
297
|
+
test('encoded', ()=>{
|
|
298
|
+
expect(Punycode.toUnicode(encoded)).to.equal(encoded);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
suite('toASCII', ()=>{
|
|
305
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.domains)){
|
|
306
|
+
suite(description, ()=>{
|
|
307
|
+
test('success', ()=>{
|
|
308
|
+
expect(Punycode.toASCII(decoded)).to.equal(encoded);
|
|
309
|
+
});
|
|
310
|
+
test('idempotent', ()=>{
|
|
311
|
+
expect(Punycode.toASCII(encoded)).to.equal(encoded);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
suite('Does not convert domain names (or other strings) that are already in ASCII', ()=>{
|
|
316
|
+
for (const [description, { encoded }] of Object.entries(testData.strings)){
|
|
317
|
+
test(description, ()=>{
|
|
318
|
+
expect(Punycode.toASCII(encoded)).to.equal(encoded);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
suite('Supports IDNA2003 separators for backwards compatibility', ()=>{
|
|
323
|
+
for (const [description, { decoded, encoded }] of Object.entries(testData.separators)){
|
|
324
|
+
test(description, ()=>{
|
|
325
|
+
expect(Punycode.toASCII(decoded)).to.equal(encoded);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
//# sourceMappingURL=punycode.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/tests/unit/punycode.spec.ts"],"sourceRoot":"","names":["expect","suite","test","Punycode","testData","strings","decoded","encoded","Czech","Hebrew","Spanish","Vietnamese","d9juau41awczczp","ucs2","domains","emoji","separators","description","Object","entries","ucs2Decode","to","deep","equal","String","fromCodePoint","ucs2Encode","map","txt","codePointAt","codePoints","decode","throw","RangeError","encode","toUnicode","toASCII"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,KAAK,EAAEC,IAAI,QAAQ,cAAc;AAC1C,YAAYC,cAAc,eAAe;AAEzC,MAAMC,WAAW;IACbC,SAAS;QACL,6BAA6B;YACzBC,SAAS;YACTC,SAAS;QACb;QACA,gCAAgC;YAC5BD,SAAS;YACTC,SAAS;QACb;QACA,iCAAiC;YAC7BD,SAAS;YACTC,SAAS;QACb;QACA,yCAAyC;YACrC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AE,CAACE,KAAK,CAAChB;gBAC/C;YACJ;QACJ;QAEAN,MAAM,8EAA8E;YAChF,KAAK,MAAM,CAACgB,aAAa,EAAEV,OAAO,EAAE,CAAC,IAAIW,OAAOC,OAAO,CAACf,SAASC,OAAO,EAAG;gBACvEH,KAAKe,aAAa;oBACdjB,OAAOG,SAASiC,OAAO,CAAC7B,UAAUc,EAAE,CAACE,KAAK,CAAChB;gBAC/C;YACJ;QACJ;QAEAN,MAAM,4DAA4D;YAC9D,KAAK,MAAM,CAACgB,aAAa,EAAEX,OAAO,EAAEC,OAAO,EAAE,CAAC,IAAIW,OAAOC,OAAO,CAACf,SAASY,UAAU,EAAG;gBACnFd,KAAKe,aAAa;oBACdjB,OAAOG,SAASiC,OAAO,CAAC9B,UAAUe,EAAE,CAACE,KAAK,CAAChB;gBAC/C;YACJ;QACJ;IACJ;AACJ","file":"punycode.spec.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.5.4"}
|
package/eslint.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "punycode-esm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Typescript + ESM version of punycode.js",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=20"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"author": "
|
|
9
|
+
"author": "JacobLey",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"repository": "
|
|
12
|
-
"homepage": "https://github.com/JacobLey/
|
|
11
|
+
"repository": "JacobLey/leyman",
|
|
12
|
+
"homepage": "https://github.com/JacobLey/leyman/tree/main/tools/punycode-esm#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/JacobLey/leyman/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"punycode",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": "./dist/punycode.js"
|
|
26
26
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"@types/mocha": "^9.1.1",
|
|
30
|
-
"@types/node": "^18.0.0",
|
|
31
|
-
"chai": "^4.3.6",
|
|
32
|
-
"mocha": "^10.0.0",
|
|
33
|
-
"nyc": "^15.1.0",
|
|
34
|
-
"typescript": "^4.7.2"
|
|
27
|
+
"imports": {
|
|
28
|
+
"#errors": "./dist/lib/errors.js"
|
|
35
29
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@biomejs/biome": "^1.8.3",
|
|
32
|
+
"@types/chai": "^4.3.17",
|
|
33
|
+
"@types/mocha": "^10.0.7",
|
|
34
|
+
"@types/node": "^22.1.0",
|
|
35
|
+
"c8": "^10.1.2",
|
|
36
|
+
"chai": "^5.1.1",
|
|
37
|
+
"mocha": "^10.7.0",
|
|
38
|
+
"typescript": "^5.5.4",
|
|
39
|
+
"nx-update-ts-references": "^0.0.3",
|
|
40
|
+
"mocha-chain": "^0.0.2",
|
|
41
|
+
"nx-tsc": "^0.0.7",
|
|
42
|
+
"@leyman/eslint-config": "^0.0.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/project.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
3
|
+
"name": "punycode-esm",
|
|
4
|
+
"targets": {
|
|
5
|
+
"biome": {},
|
|
6
|
+
"eslint": {},
|
|
7
|
+
"update-ts-references": {},
|
|
8
|
+
"tsc": {},
|
|
9
|
+
"coverage-reset": {},
|
|
10
|
+
"mocha-unit-test": {},
|
|
11
|
+
"coverage-report": {},
|
|
12
|
+
"analyze:_": {},
|
|
13
|
+
"analyze:format": {},
|
|
14
|
+
"analyze:lint": {},
|
|
15
|
+
"analyze": {},
|
|
16
|
+
"build:_": {},
|
|
17
|
+
"build:pre": {},
|
|
18
|
+
"build:run": {},
|
|
19
|
+
"build:post": {},
|
|
20
|
+
"build": {},
|
|
21
|
+
"test:_": {},
|
|
22
|
+
"test:reset": {},
|
|
23
|
+
"test:run": {},
|
|
24
|
+
"test:report": {},
|
|
25
|
+
"test": {}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const errors = {
|
|
2
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
3
|
+
'invalid-input': 'Invalid input',
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A generic error utility function.
|
|
8
|
+
*
|
|
9
|
+
* @param type - The error type key.
|
|
10
|
+
* @throws Throws a `RangeError` with the applicable error message.
|
|
11
|
+
*/
|
|
12
|
+
export const rangeError = (type: keyof typeof errors): never => {
|
|
13
|
+
throw new RangeError(errors[type]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const checkOverflow = (
|
|
17
|
+
lower: number,
|
|
18
|
+
upper: number,
|
|
19
|
+
{
|
|
20
|
+
gte = false,
|
|
21
|
+
error,
|
|
22
|
+
}: {
|
|
23
|
+
gte?: boolean;
|
|
24
|
+
error?: keyof typeof errors;
|
|
25
|
+
} = {}
|
|
26
|
+
): void => {
|
|
27
|
+
if (gte ? lower >= upper : lower > upper) {
|
|
28
|
+
throw new RangeError(
|
|
29
|
+
error ? errors[error] : 'Overflow: input needs wider integers to process'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
};
|