bare-url 0.3.7 → 1.0.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 (42) hide show
  1. package/CMakeLists.txt +27 -0
  2. package/binding.c +111 -0
  3. package/binding.js +1 -0
  4. package/index.js +74 -90
  5. package/lib/errors.js +0 -105
  6. package/package.json +14 -3
  7. package/prebuilds/darwin-arm64/bare-url.bare +0 -0
  8. package/prebuilds/darwin-x64/bare-url.bare +0 -0
  9. package/prebuilds/linux-arm64/bare-url.bare +0 -0
  10. package/prebuilds/linux-x64/bare-url.bare +0 -0
  11. package/prebuilds/win32-x64/bare-url.bare +0 -0
  12. package/vendor/liburl/CMakeLists.txt +79 -0
  13. package/vendor/liburl/LICENSE +201 -0
  14. package/vendor/liburl/README.md +27 -0
  15. package/vendor/liburl/include/url.h +107 -0
  16. package/vendor/liburl/src/character-set.h +41 -0
  17. package/vendor/liburl/src/idna.h +14 -0
  18. package/vendor/liburl/src/infra.h +141 -0
  19. package/vendor/liburl/src/parse.h +1390 -0
  20. package/vendor/liburl/src/percent-encode.h +567 -0
  21. package/vendor/liburl/src/punycode.h +21 -0
  22. package/vendor/liburl/src/serialize.h +91 -0
  23. package/vendor/liburl/src/type.h +61 -0
  24. package/vendor/liburl/src/url.c +81 -0
  25. package/vendor/libutf/CMakeLists.txt +76 -0
  26. package/vendor/libutf/LICENSE +201 -0
  27. package/vendor/libutf/README.md +11 -0
  28. package/vendor/libutf/include/utf/endianness.h +54 -0
  29. package/vendor/libutf/include/utf/string.h +759 -0
  30. package/vendor/libutf/include/utf.h +45 -0
  31. package/vendor/libutf/src/endianness.c +19 -0
  32. package/vendor/libutf/src/utf16/utf8-convert.c +77 -0
  33. package/vendor/libutf/src/utf16/utf8-length.c +45 -0
  34. package/vendor/libutf/src/utf16/validate.c +53 -0
  35. package/vendor/libutf/src/utf8/string.c +148 -0
  36. package/vendor/libutf/src/utf8/utf16-convert.c +90 -0
  37. package/vendor/libutf/src/utf8/utf16-length.c +39 -0
  38. package/vendor/libutf/src/utf8/validate.c +107 -0
  39. package/lib/constants.js +0 -25
  40. package/lib/infra.js +0 -39
  41. package/lib/parse.js +0 -941
  42. package/lib/serialize.js +0 -98
@@ -0,0 +1,567 @@
1
+ #ifndef URL_PERCENT_ENCODE
2
+ #define URL_PERCENT_ENCODE
3
+
4
+ #include <stddef.h>
5
+ #include <stdint.h>
6
+ #include <utf.h>
7
+ #include <utf/string.h>
8
+
9
+ #include "character-set.h"
10
+ #include "infra.h"
11
+
12
+ // https://url.spec.whatwg.org/#percent-encode
13
+ static const utf8_t url__hex_encoded[768] =
14
+ "%00%01%02%03%04%05%06%07"
15
+ "%08%09%0A%0B%0C%0D%0E%0F"
16
+ "%10%11%12%13%14%15%16%17"
17
+ "%18%19%1A%1B%1C%1D%1E%1F"
18
+ "%20%21%22%23%24%25%26%27"
19
+ "%28%29%2A%2B%2C%2D%2E%2F"
20
+ "%30%31%32%33%34%35%36%37"
21
+ "%38%39%3A%3B%3C%3D%3E%3F"
22
+ "%40%41%42%43%44%45%46%47"
23
+ "%48%49%4A%4B%4C%4D%4E%4F"
24
+ "%50%51%52%53%54%55%56%57"
25
+ "%58%59%5A%5B%5C%5D%5E%5F"
26
+ "%60%61%62%63%64%65%66%67"
27
+ "%68%69%6A%6B%6C%6D%6E%6F"
28
+ "%70%71%72%73%74%75%76%77"
29
+ "%78%79%7A%7B%7C%7D%7E%7F"
30
+ "%80%81%82%83%84%85%86%87"
31
+ "%88%89%8A%8B%8C%8D%8E%8F"
32
+ "%90%91%92%93%94%95%96%97"
33
+ "%98%99%9A%9B%9C%9D%9E%9F"
34
+ "%A0%A1%A2%A3%A4%A5%A6%A7"
35
+ "%A8%A9%AA%AB%AC%AD%AE%AF"
36
+ "%B0%B1%B2%B3%B4%B5%B6%B7"
37
+ "%B8%B9%BA%BB%BC%BD%BE%BF"
38
+ "%C0%C1%C2%C3%C4%C5%C6%C7"
39
+ "%C8%C9%CA%CB%CC%CD%CE%CF"
40
+ "%D0%D1%D2%D3%D4%D5%D6%D7"
41
+ "%D8%D9%DA%DB%DC%DD%DE%DF"
42
+ "%E0%E1%E2%E3%E4%E5%E6%E7"
43
+ "%E8%E9%EA%EB%EC%ED%EE%EF"
44
+ "%F0%F1%F2%F3%F4%F5%F6%F7"
45
+ "%F8%F9%FA%FB%FC%FD%FE%FF";
46
+
47
+ // https://url.spec.whatwg.org/#percent-decode
48
+ static const uint8_t url__hex_decoded[256] = {
49
+ ['0'] = 0,
50
+ ['1'] = 1,
51
+ ['2'] = 2,
52
+ ['3'] = 3,
53
+ ['4'] = 4,
54
+ ['5'] = 5,
55
+ ['6'] = 6,
56
+ ['7'] = 7,
57
+ ['8'] = 8,
58
+ ['9'] = 9,
59
+ ['A'] = 10,
60
+ ['a'] = 10,
61
+ ['B'] = 11,
62
+ ['b'] = 11,
63
+ ['C'] = 12,
64
+ ['c'] = 12,
65
+ ['D'] = 13,
66
+ ['d'] = 13,
67
+ ['E'] = 14,
68
+ ['e'] = 14,
69
+ ['F'] = 15,
70
+ ['f'] = 15,
71
+ };
72
+
73
+ static inline int
74
+ url__percent_encode_character (utf8_t character, url_character_set_t percent_encode_set, utf8_string_t *result) {
75
+ int err;
76
+
77
+ if (url__is_in_character_set(percent_encode_set, character)) {
78
+ err = utf8_string_append_literal(result, &url__hex_encoded[(character << 1) + character], 3);
79
+ } else {
80
+ err = utf8_string_append_character(result, character);
81
+ }
82
+
83
+ return err;
84
+ }
85
+
86
+ static inline int
87
+ url__percent_encode_string (const utf8_string_view_t view, url_character_set_t percent_encode_set, utf8_string_t *result) {
88
+ int err;
89
+
90
+ size_t i = 0;
91
+
92
+ for (size_t n = view.len; i < n; i++) {
93
+ if (url__is_in_character_set(percent_encode_set, view.data[i])) {
94
+ break;
95
+ }
96
+ }
97
+
98
+ if (i == view.len) return utf8_string_append_view(result, view);
99
+
100
+ err = utf8_string_reserve(result, result->len + view.len);
101
+ if (err < 0) return err;
102
+
103
+ err = utf8_string_append_view(result, utf8_string_view_substring(view, 0, i));
104
+ if (err < 0) return err;
105
+
106
+ for (size_t n = view.len; i < n; i++) {
107
+ err = url__percent_encode_character(view.data[i], percent_encode_set, result);
108
+ if (err < 0) return err;
109
+ }
110
+
111
+ return 0;
112
+ }
113
+
114
+ static inline int
115
+ url__percent_decode_character (const utf8_t *character, utf8_string_t *result) {
116
+ return utf8_string_append_character(result, url__hex_decoded[character[0]] * 0x10 + url__hex_decoded[character[1]]);
117
+ }
118
+
119
+ static inline int
120
+ url__percent_decode_string (const utf8_string_view_t view, utf8_string_t *result) {
121
+ int err;
122
+
123
+ size_t i = 0;
124
+
125
+ for (size_t n = view.len; i < n; i++) {
126
+ if (view.data[i] == 0x25) {
127
+ break;
128
+ }
129
+ }
130
+
131
+ err = utf8_string_reserve(result, result->len + view.len);
132
+ if (err < 0) return err;
133
+
134
+ err = utf8_string_append_view(result, utf8_string_view_substring(view, 0, i));
135
+ if (err < 0) return err;
136
+
137
+ for (size_t n = view.len; i < n; i++) {
138
+ utf8_t c = view.data[i];
139
+
140
+ if (
141
+ c == 0x25 &&
142
+ i + 2 < n &&
143
+ url__is_ascii_alphanumeric(view.data[i + 1]) &&
144
+ url__is_ascii_alphanumeric(view.data[i + 2])
145
+ ) {
146
+ err = url__percent_decode_character(&view.data[i + 1], result);
147
+ if (err < 0) return err;
148
+
149
+ i += 2;
150
+ } else {
151
+ err = utf8_string_append_character(result, c);
152
+ if (err < 0) return err;
153
+ }
154
+ }
155
+
156
+ return 0;
157
+ }
158
+
159
+ // https://url.spec.whatwg.org/#c0-control-percent-encode-set
160
+ static url_character_set_t url__c0_control_percent_encode_set = {
161
+ // 00 01 02 03 04 05 06 07
162
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
163
+ // 08 09 0a 0b 0c 0d 0e 0f
164
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
165
+ // 10 11 12 13 14 15 16 17
166
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
167
+ // 18 19 1a 1b 1c 1d 1e 1f
168
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
169
+ // 20 21 22 23 24 25 26 27
170
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
171
+ // 28 29 2a 2b 2c 2d 2e 2f
172
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
173
+ // 30 31 32 33 34 35 36 37
174
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
175
+ // 38 39 3a 3b 3c 3d 3e 3f
176
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
177
+ // 40 41 42 43 44 45 46 47
178
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
179
+ // 48 49 4a 4b 4c 4d 4e 4f
180
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
181
+ // 50 51 52 53 54 55 56 57
182
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
183
+ // 58 59 5a 5b 5c 5d 5e 5f
184
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
185
+ // 60 61 62 63 64 65 66 67
186
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
187
+ // 68 69 6a 6b 6c 6d 6e 6f
188
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
189
+ // 70 71 72 73 74 75 76 77
190
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
191
+ // 78 79 7a 7b 7c 7d 7e 7f
192
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x80,
193
+ // 80 81 82 83 84 85 86 87
194
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
195
+ // 88 89 8a 8b 8c 8d 8e 8f
196
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
197
+ // 90 91 92 93 94 95 96 97
198
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
199
+ // 98 99 9a 9b 9c 9d 9e 9f
200
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
201
+ // a0 a1 a2 a3 a4 a5 a6 a7
202
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
203
+ // a8 a9 aa ab ac ad ae af
204
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
205
+ // b0 b1 b2 b3 b4 b5 b6 b7
206
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
207
+ // b8 b9 ba bb bc bd be bf
208
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
209
+ // c0 c1 c2 c3 c4 c5 c6 c7
210
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
211
+ // c8 c9 ca cb cc cd ce cf
212
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
213
+ // d0 d1 d2 d3 d4 d5 d6 d7
214
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
215
+ // d8 d9 da db dc dd de df
216
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
217
+ // e0 e1 e2 e3 e4 e5 e6 e7
218
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
219
+ // e8 e9 ea eb ec ed ee ef
220
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
221
+ // f0 f1 f2 f3 f4 f5 f6 f7
222
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
223
+ // f8 f9 fa fb fc fd fe ff
224
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
225
+ };
226
+
227
+ // https://url.spec.whatwg.org/#query-percent-encode-set
228
+ static url_character_set_t url__query_percent_encode_set = {
229
+ // 00 01 02 03 04 05 06 07
230
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
231
+ // 08 09 0a 0b 0c 0d 0e 0f
232
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
233
+ // 10 11 12 13 14 15 16 17
234
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
235
+ // 18 19 1a 1b 1c 1d 1e 1f
236
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
237
+ // 20 21 22 23 24 25 26 27
238
+ 0x01 | 0x00 | 0x04 | 0x08 | 0x00 | 0x00 | 0x00 | 0x00,
239
+ // 28 29 2a 2b 2c 2d 2e 2f
240
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
241
+ // 30 31 32 33 34 35 36 37
242
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
243
+ // 38 39 3a 3b 3c 3d 3e 3f
244
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x40 | 0x00,
245
+ // 40 41 42 43 44 45 46 47
246
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
247
+ // 48 49 4a 4b 4c 4d 4e 4f
248
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
249
+ // 50 51 52 53 54 55 56 57
250
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
251
+ // 58 59 5a 5b 5c 5d 5e 5f
252
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
253
+ // 60 61 62 63 64 65 66 67
254
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
255
+ // 68 69 6a 6b 6c 6d 6e 6f
256
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
257
+ // 70 71 72 73 74 75 76 77
258
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
259
+ // 78 79 7a 7b 7c 7d 7e 7f
260
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x80,
261
+ // 80 81 82 83 84 85 86 87
262
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
263
+ // 88 89 8a 8b 8c 8d 8e 8f
264
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
265
+ // 90 91 92 93 94 95 96 97
266
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
267
+ // 98 99 9a 9b 9c 9d 9e 9f
268
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
269
+ // a0 a1 a2 a3 a4 a5 a6 a7
270
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
271
+ // a8 a9 aa ab ac ad ae af
272
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
273
+ // b0 b1 b2 b3 b4 b5 b6 b7
274
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
275
+ // b8 b9 ba bb bc bd be bf
276
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
277
+ // c0 c1 c2 c3 c4 c5 c6 c7
278
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
279
+ // c8 c9 ca cb cc cd ce cf
280
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
281
+ // d0 d1 d2 d3 d4 d5 d6 d7
282
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
283
+ // d8 d9 da db dc dd de df
284
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
285
+ // e0 e1 e2 e3 e4 e5 e6 e7
286
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
287
+ // e8 e9 ea eb ec ed ee ef
288
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
289
+ // f0 f1 f2 f3 f4 f5 f6 f7
290
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
291
+ // f8 f9 fa fb fc fd fe ff
292
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
293
+ };
294
+
295
+ // https://url.spec.whatwg.org/#special-query-percent-encode-set
296
+ static url_character_set_t url__special_query_percent_encode_set = {
297
+ // 00 01 02 03 04 05 06 07
298
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
299
+ // 08 09 0a 0b 0c 0d 0e 0f
300
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
301
+ // 10 11 12 13 14 15 16 17
302
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
303
+ // 18 19 1a 1b 1c 1d 1e 1f
304
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
305
+ // 20 21 22 23 24 25 26 27
306
+ 0x01 | 0x00 | 0x04 | 0x08 | 0x00 | 0x00 | 0x00 | 0x80,
307
+ // 28 29 2a 2b 2c 2d 2e 2f
308
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
309
+ // 30 31 32 33 34 35 36 37
310
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
311
+ // 38 39 3a 3b 3c 3d 3e 3f
312
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x40 | 0x00,
313
+ // 40 41 42 43 44 45 46 47
314
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
315
+ // 48 49 4a 4b 4c 4d 4e 4f
316
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
317
+ // 50 51 52 53 54 55 56 57
318
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
319
+ // 58 59 5a 5b 5c 5d 5e 5f
320
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
321
+ // 60 61 62 63 64 65 66 67
322
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
323
+ // 68 69 6a 6b 6c 6d 6e 6f
324
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
325
+ // 70 71 72 73 74 75 76 77
326
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
327
+ // 78 79 7a 7b 7c 7d 7e 7f
328
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x80,
329
+ // 80 81 82 83 84 85 86 87
330
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
331
+ // 88 89 8a 8b 8c 8d 8e 8f
332
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
333
+ // 90 91 92 93 94 95 96 97
334
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
335
+ // 98 99 9a 9b 9c 9d 9e 9f
336
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
337
+ // a0 a1 a2 a3 a4 a5 a6 a7
338
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
339
+ // a8 a9 aa ab ac ad ae af
340
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
341
+ // b0 b1 b2 b3 b4 b5 b6 b7
342
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
343
+ // b8 b9 ba bb bc bd be bf
344
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
345
+ // c0 c1 c2 c3 c4 c5 c6 c7
346
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
347
+ // c8 c9 ca cb cc cd ce cf
348
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
349
+ // d0 d1 d2 d3 d4 d5 d6 d7
350
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
351
+ // d8 d9 da db dc dd de df
352
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
353
+ // e0 e1 e2 e3 e4 e5 e6 e7
354
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
355
+ // e8 e9 ea eb ec ed ee ef
356
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
357
+ // f0 f1 f2 f3 f4 f5 f6 f7
358
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
359
+ // f8 f9 fa fb fc fd fe ff
360
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
361
+ };
362
+
363
+ // https://url.spec.whatwg.org/#fragment-percent-encode-set
364
+ static url_character_set_t url__fragment_percent_encode_set = {
365
+ // 00 01 02 03 04 05 06 07
366
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
367
+ // 08 09 0a 0b 0c 0d 0e 0f
368
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
369
+ // 10 11 12 13 14 15 16 17
370
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
371
+ // 18 19 1a 1b 1c 1d 1e 1f
372
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
373
+ // 20 21 22 23 24 25 26 27
374
+ 0x01 | 0x00 | 0x04 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
375
+ // 28 29 2a 2b 2c 2d 2e 2f
376
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
377
+ // 30 31 32 33 34 35 36 37
378
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
379
+ // 38 39 3a 3b 3c 3d 3e 3f
380
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x40 | 0x00,
381
+ // 40 41 42 43 44 45 46 47
382
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
383
+ // 48 49 4a 4b 4c 4d 4e 4f
384
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
385
+ // 50 51 52 53 54 55 56 57
386
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
387
+ // 58 59 5a 5b 5c 5d 5e 5f
388
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
389
+ // 60 61 62 63 64 65 66 67
390
+ 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
391
+ // 68 69 6a 6b 6c 6d 6e 6f
392
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
393
+ // 70 71 72 73 74 75 76 77
394
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
395
+ // 78 79 7a 7b 7c 7d 7e 7f
396
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x80,
397
+ // 80 81 82 83 84 85 86 87
398
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
399
+ // 88 89 8a 8b 8c 8d 8e 8f
400
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
401
+ // 90 91 92 93 94 95 96 97
402
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
403
+ // 98 99 9a 9b 9c 9d 9e 9f
404
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
405
+ // a0 a1 a2 a3 a4 a5 a6 a7
406
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
407
+ // a8 a9 aa ab ac ad ae af
408
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
409
+ // b0 b1 b2 b3 b4 b5 b6 b7
410
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
411
+ // b8 b9 ba bb bc bd be bf
412
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
413
+ // c0 c1 c2 c3 c4 c5 c6 c7
414
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
415
+ // c8 c9 ca cb cc cd ce cf
416
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
417
+ // d0 d1 d2 d3 d4 d5 d6 d7
418
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
419
+ // d8 d9 da db dc dd de df
420
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
421
+ // e0 e1 e2 e3 e4 e5 e6 e7
422
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
423
+ // e8 e9 ea eb ec ed ee ef
424
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
425
+ // f0 f1 f2 f3 f4 f5 f6 f7
426
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
427
+ // f8 f9 fa fb fc fd fe ff
428
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
429
+ };
430
+
431
+ // https://url.spec.whatwg.org/#userinfo-percent-encode-set
432
+ static url_character_set_t url__userinfo_percent_encode_set = {
433
+ // 00 01 02 03 04 05 06 07
434
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
435
+ // 08 09 0a 0b 0c 0d 0e 0f
436
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
437
+ // 10 11 12 13 14 15 16 17
438
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
439
+ // 18 19 1a 1b 1c 1d 1e 1f
440
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
441
+ // 20 21 22 23 24 25 26 27
442
+ 0x01 | 0x00 | 0x04 | 0x08 | 0x00 | 0x00 | 0x00 | 0x00,
443
+ // 28 29 2a 2b 2c 2d 2e 2f
444
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x80,
445
+ // 30 31 32 33 34 35 36 37
446
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
447
+ // 38 39 3a 3b 3c 3d 3e 3f
448
+ 0x00 | 0x00 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
449
+ // 40 41 42 43 44 45 46 47
450
+ 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
451
+ // 48 49 4a 4b 4c 4d 4e 4f
452
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
453
+ // 50 51 52 53 54 55 56 57
454
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
455
+ // 58 59 5a 5b 5c 5d 5e 5f
456
+ 0x00 | 0x00 | 0x00 | 0x08 | 0x10 | 0x20 | 0x40 | 0x00,
457
+ // 60 61 62 63 64 65 66 67
458
+ 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
459
+ // 68 69 6a 6b 6c 6d 6e 6f
460
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
461
+ // 70 71 72 73 74 75 76 77
462
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
463
+ // 78 79 7a 7b 7c 7d 7e 7f
464
+ 0x00 | 0x00 | 0x00 | 0x08 | 0x10 | 0x20 | 0x00 | 0x80,
465
+ // 80 81 82 83 84 85 86 87
466
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
467
+ // 88 89 8a 8b 8c 8d 8e 8f
468
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
469
+ // 90 91 92 93 94 95 96 97
470
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
471
+ // 98 99 9a 9b 9c 9d 9e 9f
472
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
473
+ // a0 a1 a2 a3 a4 a5 a6 a7
474
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
475
+ // a8 a9 aa ab ac ad ae af
476
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
477
+ // b0 b1 b2 b3 b4 b5 b6 b7
478
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
479
+ // b8 b9 ba bb bc bd be bf
480
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
481
+ // c0 c1 c2 c3 c4 c5 c6 c7
482
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
483
+ // c8 c9 ca cb cc cd ce cf
484
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
485
+ // d0 d1 d2 d3 d4 d5 d6 d7
486
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
487
+ // d8 d9 da db dc dd de df
488
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
489
+ // e0 e1 e2 e3 e4 e5 e6 e7
490
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
491
+ // e8 e9 ea eb ec ed ee ef
492
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
493
+ // f0 f1 f2 f3 f4 f5 f6 f7
494
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
495
+ // f8 f9 fa fb fc fd fe ff
496
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
497
+ };
498
+
499
+ // https://url.spec.whatwg.org/#path-percent-encode-set
500
+ static url_character_set_t url__path_percent_encode_set = {
501
+ // 00 01 02 03 04 05 06 07
502
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
503
+ // 08 09 0a 0b 0c 0d 0e 0f
504
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
505
+ // 10 11 12 13 14 15 16 17
506
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
507
+ // 18 19 1a 1b 1c 1d 1e 1f
508
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
509
+ // 20 21 22 23 24 25 26 27
510
+ 0x01 | 0x00 | 0x04 | 0x08 | 0x00 | 0x00 | 0x00 | 0x00,
511
+ // 28 29 2a 2b 2c 2d 2e 2f
512
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
513
+ // 30 31 32 33 34 35 36 37
514
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
515
+ // 38 39 3a 3b 3c 3d 3e 3f
516
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x40 | 0x80,
517
+ // 40 41 42 43 44 45 46 47
518
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
519
+ // 48 49 4a 4b 4c 4d 4e 4f
520
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
521
+ // 50 51 52 53 54 55 56 57
522
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
523
+ // 58 59 5a 5b 5c 5d 5e 5f
524
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
525
+ // 60 61 62 63 64 65 66 67
526
+ 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
527
+ // 68 69 6a 6b 6c 6d 6e 6f
528
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
529
+ // 70 71 72 73 74 75 76 77
530
+ 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
531
+ // 78 79 7a 7b 7c 7d 7e 7f
532
+ 0x00 | 0x00 | 0x00 | 0x08 | 0x00 | 0x20 | 0x00 | 0x80,
533
+ // 80 81 82 83 84 85 86 87
534
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
535
+ // 88 89 8a 8b 8c 8d 8e 8f
536
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
537
+ // 90 91 92 93 94 95 96 97
538
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
539
+ // 98 99 9a 9b 9c 9d 9e 9f
540
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
541
+ // a0 a1 a2 a3 a4 a5 a6 a7
542
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
543
+ // a8 a9 aa ab ac ad ae af
544
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
545
+ // b0 b1 b2 b3 b4 b5 b6 b7
546
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
547
+ // b8 b9 ba bb bc bd be bf
548
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
549
+ // c0 c1 c2 c3 c4 c5 c6 c7
550
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
551
+ // c8 c9 ca cb cc cd ce cf
552
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
553
+ // d0 d1 d2 d3 d4 d5 d6 d7
554
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
555
+ // d8 d9 da db dc dd de df
556
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
557
+ // e0 e1 e2 e3 e4 e5 e6 e7
558
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
559
+ // e8 e9 ea eb ec ed ee ef
560
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
561
+ // f0 f1 f2 f3 f4 f5 f6 f7
562
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
563
+ // f8 f9 fa fb fc fd fe ff
564
+ 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
565
+ };
566
+
567
+ #endif // URL_PERCENT_ENCODE
@@ -0,0 +1,21 @@
1
+ #ifndef URL_PUNYCODE_H
2
+ #define URL_PUNYCODE_H
3
+
4
+ #include <utf.h>
5
+ #include <utf/string.h>
6
+
7
+ static inline int
8
+ url__punycode_to_utf8 (utf8_string_view_t input, utf8_string_t *result) {
9
+ // TODO
10
+
11
+ return -1;
12
+ }
13
+
14
+ static inline int
15
+ url__utf8_to_punycode (utf8_string_view_t input, utf8_string_t *result) {
16
+ // TODO
17
+
18
+ return -1;
19
+ }
20
+
21
+ #endif // URL_PUNYCODE_H
@@ -0,0 +1,91 @@
1
+ #ifndef URL_SERIALIZE_H
2
+ #define URL_SERIALIZE_H
3
+
4
+ #include <stdint.h>
5
+ #include <stdio.h>
6
+ #include <utf.h>
7
+ #include <utf/string.h>
8
+
9
+ // https://url.spec.whatwg.org/#concept-ipv4-serializer
10
+ static inline int
11
+ url__serialize_ipv4 (uint32_t address, utf8_string_t *result) {
12
+ int err;
13
+
14
+ uint32_t n = address;
15
+
16
+ for (uint8_t i = 3; i <= 3; i--) {
17
+ char number[4];
18
+ err = snprintf(number, 4, "%d", (address >> (i * 8)) & 0xff);
19
+ assert(err > 0);
20
+
21
+ err = utf8_string_append_literal(result, (utf8_t *) number, err);
22
+ if (err < 0) return err;
23
+
24
+ if (i != 0) {
25
+ err = utf8_string_append_character(result, '.');
26
+ if (err < 0) return err;
27
+ }
28
+ }
29
+
30
+ return 0;
31
+ }
32
+
33
+ // https://url.spec.whatwg.org/#concept-ipv6-serializer
34
+ static inline int
35
+ url__serialize_ipv6 (uint16_t address[8], utf8_string_t *result) {
36
+ int err;
37
+
38
+ uint8_t compress_length = 0;
39
+ uint8_t compress = 8;
40
+
41
+ for (size_t i = 0; i < 8; i++) {
42
+ if (address[i] == 0) {
43
+ size_t next = i + 1;
44
+
45
+ while (next < 8 && address[next] == 0) {
46
+ next++;
47
+ }
48
+
49
+ uint8_t count = next - i;
50
+
51
+ if (compress_length < count) {
52
+ compress_length = count;
53
+ compress = i;
54
+ if (next == 8) break;
55
+ i = next;
56
+ }
57
+ }
58
+ }
59
+
60
+ bool ignore_0 = false;
61
+
62
+ for (uint8_t piece_index = 0; piece_index < 8; piece_index++) {
63
+ if (ignore_0 && address[piece_index] == 0) continue;
64
+
65
+ ignore_0 = false;
66
+
67
+ if (compress == piece_index) {
68
+ err = utf8_string_append_literal(result, (utf8_t *) "::", piece_index == 0 ? 2 : 1);
69
+ if (err < 0) return err;
70
+
71
+ ignore_0 = true;
72
+ continue;
73
+ }
74
+
75
+ char number[5];
76
+ err = snprintf(number, 5, "%x", address[piece_index]);
77
+ assert(err > 0);
78
+
79
+ err = utf8_string_append_literal(result, (utf8_t *) number, err);
80
+ if (err < 0) return err;
81
+
82
+ if (piece_index != 7) {
83
+ err = utf8_string_append_character(result, ':');
84
+ if (err < 0) return err;
85
+ }
86
+ }
87
+
88
+ return 0;
89
+ }
90
+
91
+ #endif // URL_SERIALIZE_H