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
package/lib/serialize.js DELETED
@@ -1,98 +0,0 @@
1
- // https://url.spec.whatwg.org/#url-serializing
2
- module.exports = exports = function serialize (url, excludeFragment = false) {
3
- let output = url.scheme + ':'
4
-
5
- if (url.host !== null) {
6
- output += '//'
7
-
8
- if (url.username !== '' || url.password !== '') {
9
- output += url.username
10
-
11
- if (url.password !== '') {
12
- output += ':' + url.password
13
- }
14
-
15
- output += '@'
16
- }
17
-
18
- output += serializeHost(url.host)
19
-
20
- if (url.port !== null) {
21
- output += ':' + url.port.toString(10)
22
- }
23
- }
24
-
25
- if (
26
- url.host === null &&
27
- typeof url.path !== 'string' &&
28
- url.path.length > 1 &&
29
- url.path[0] === ''
30
- ) {
31
- output += '/.'
32
- }
33
-
34
- if (typeof url.path === 'string') {
35
- output += url.path
36
- } else {
37
- for (const segment of url.path) output += '/' + segment
38
- }
39
-
40
- if (url.query !== null) {
41
- output += '?' + url.query
42
- }
43
-
44
- if (url.fragment !== null && !excludeFragment) {
45
- output += '#' + url.fragment
46
- }
47
-
48
- return output
49
- }
50
-
51
- // https://url.spec.whatwg.org/#concept-host-serializer
52
- const serializeHost = exports.host = function serializeHost (host) {
53
- if (typeof host === 'number') return serializeIPv4(host)
54
- if (typeof host !== 'string') return '[' + serializeIPv6(host) + ']'
55
-
56
- return host
57
- }
58
-
59
- // https://url.spec.whatwg.org/#concept-ipv4-serializer
60
- function serializeIPv4 (address) {
61
- let output = ''
62
- let n = address
63
-
64
- for (let i = 1; i <= 4; i++) {
65
- output = (n % 256).toString(10) + output
66
-
67
- if (i !== 4) output = '.' + output
68
-
69
- n = n / 256 | 0
70
- }
71
-
72
- return output
73
- }
74
-
75
- // https://url.spec.whatwg.org/#concept-ipv6-serializer
76
- function serializeIPv6 (address) {
77
- let output = ''
78
- const compress = 8 // TODO Find first longest 0 sequence
79
- let ignore0 = false
80
-
81
- for (let pieceIndex = 0; pieceIndex <= 7; pieceIndex++) {
82
- if (ignore0 && address[pieceIndex] === 0) continue
83
-
84
- ignore0 = false
85
-
86
- if (compress === pieceIndex) {
87
- output += pieceIndex === 0 ? '::' : ':'
88
- ignore0 = true
89
- continue
90
- }
91
-
92
- output += address[pieceIndex].toString(16)
93
-
94
- if (pieceIndex !== 7) output += ':'
95
- }
96
-
97
- return output
98
- }