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.
- package/CMakeLists.txt +27 -0
- package/binding.c +111 -0
- package/binding.js +1 -0
- package/index.js +74 -90
- package/lib/errors.js +0 -105
- package/package.json +14 -3
- package/prebuilds/darwin-arm64/bare-url.bare +0 -0
- package/prebuilds/darwin-x64/bare-url.bare +0 -0
- package/prebuilds/linux-arm64/bare-url.bare +0 -0
- package/prebuilds/linux-x64/bare-url.bare +0 -0
- package/prebuilds/win32-x64/bare-url.bare +0 -0
- package/vendor/liburl/CMakeLists.txt +79 -0
- package/vendor/liburl/LICENSE +201 -0
- package/vendor/liburl/README.md +27 -0
- package/vendor/liburl/include/url.h +107 -0
- package/vendor/liburl/src/character-set.h +41 -0
- package/vendor/liburl/src/idna.h +14 -0
- package/vendor/liburl/src/infra.h +141 -0
- package/vendor/liburl/src/parse.h +1390 -0
- package/vendor/liburl/src/percent-encode.h +567 -0
- package/vendor/liburl/src/punycode.h +21 -0
- package/vendor/liburl/src/serialize.h +91 -0
- package/vendor/liburl/src/type.h +61 -0
- package/vendor/liburl/src/url.c +81 -0
- package/vendor/libutf/CMakeLists.txt +76 -0
- package/vendor/libutf/LICENSE +201 -0
- package/vendor/libutf/README.md +11 -0
- package/vendor/libutf/include/utf/endianness.h +54 -0
- package/vendor/libutf/include/utf/string.h +759 -0
- package/vendor/libutf/include/utf.h +45 -0
- package/vendor/libutf/src/endianness.c +19 -0
- package/vendor/libutf/src/utf16/utf8-convert.c +77 -0
- package/vendor/libutf/src/utf16/utf8-length.c +45 -0
- package/vendor/libutf/src/utf16/validate.c +53 -0
- package/vendor/libutf/src/utf8/string.c +148 -0
- package/vendor/libutf/src/utf8/utf16-convert.c +90 -0
- package/vendor/libutf/src/utf8/utf16-length.c +39 -0
- package/vendor/libutf/src/utf8/validate.c +107 -0
- package/lib/constants.js +0 -25
- package/lib/infra.js +0 -39
- package/lib/parse.js +0 -941
- 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
|
-
}
|