@blueking/bkui-form 1.0.1-beta.1 → 1.0.1-beta.3
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/esm/adapter/common/FieldGroupWrap.tsx.js +199 -0
- package/esm/adapter/field/ArrayField.tsx.js +55 -0
- package/esm/adapter/field/BooleanField.tsx.js +41 -0
- package/esm/adapter/field/CompositionField.tsx.js +113 -0
- package/esm/adapter/field/FieldProps.ts.js +85 -0
- package/esm/adapter/field/NumberField.tsx.js +19 -0
- package/esm/adapter/field/ObjectField.tsx.js +58 -0
- package/esm/adapter/field/SchemaField.tsx.js +28 -0
- package/esm/adapter/field/StringField.tsx.js +4 -0
- package/esm/adapter/widget/ArrayWidget.ts.js +196 -0
- package/esm/adapter/widget/ButtonWidget.ts.js +76 -0
- package/esm/adapter/widget/CheckboxWidget.ts.js +101 -0
- package/esm/adapter/widget/CollapseGroupWidget.ts.js +140 -0
- package/esm/adapter/widget/ColorPickerWidget.ts.js +71 -0
- package/esm/adapter/widget/InputWidget.ts.js +79 -0
- package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +156 -0
- package/esm/adapter/widget/RadioWidget.ts.js +98 -0
- package/esm/adapter/widget/SelectWidget.ts.js +98 -0
- package/esm/adapter/widget/SwitchWidget.ts.js +73 -0
- package/esm/adapter/widget/TabGroupWidget.ts.js +145 -0
- package/esm/adapter/widget/TableWidget.ts.js +205 -0
- package/esm/adapter/widget/Widget.ts.js +497 -0
- package/esm/assets/fonts/iconcool.eot +0 -0
- package/esm/assets/fonts/iconcool.ttf +0 -0
- package/esm/assets/fonts/iconcool.woff +0 -0
- package/esm/assets/style.css +43 -0
- package/esm/controller/form.css +164 -0
- package/esm/controller/form.tsx.js +159 -0
- package/esm/controller/props.ts.js +75 -0
- package/esm/core/events.ts.js +74 -0
- package/esm/core/expression.ts.js +67 -0
- package/esm/core/lang.ts.js +25 -0
- package/esm/core/layout.ts.js +149 -0
- package/esm/core/path.ts.js +60 -0
- package/esm/core/proxy.ts.js +10 -0
- package/esm/core/reaction.ts.js +116 -0
- package/esm/core/register.ts.js +74 -0
- package/esm/core/schema.ts.js +302 -0
- package/esm/core/validator.ts.js +248 -0
- package/esm/core/widgetTree.ts.js +163 -0
- package/esm/index.ts.js +6 -0
- package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +35 -0
- package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +233 -0
- package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +172 -0
- package/esm/node_modules/ajv/dist/ajv.js +50 -0
- package/esm/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/esm/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/esm/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/esm/node_modules/ajv/dist/compile/errors.js +123 -0
- package/esm/node_modules/ajv/dist/compile/index.js +242 -0
- package/esm/node_modules/ajv/dist/compile/names.js +28 -0
- package/esm/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/esm/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/esm/node_modules/ajv/dist/compile/rules.js +26 -0
- package/esm/node_modules/ajv/dist/compile/util.js +178 -0
- package/esm/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/esm/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/esm/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/esm/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/esm/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/esm/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/esm/node_modules/ajv/dist/core.js +618 -0
- package/esm/node_modules/ajv/dist/refs/data.json +13 -0
- package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/esm/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/esm/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/esm/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/esm/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/esm/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/esm/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/esm/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/esm/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/esm/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +24 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/esm/node_modules/ajv-formats/dist/formats.js +173 -0
- package/esm/node_modules/ajv-formats/dist/index.js +37 -0
- package/esm/node_modules/ajv-formats/dist/limit.js +69 -0
- package/esm/node_modules/ajv-i18n/localize/zh/index.js +154 -0
- package/esm/node_modules/fast-deep-equal/index.js +46 -0
- package/esm/node_modules/fast-uri/index.js +303 -0
- package/esm/node_modules/fast-uri/lib/schemes.js +188 -0
- package/esm/node_modules/fast-uri/lib/scopedChars.js +30 -0
- package/esm/node_modules/fast-uri/lib/utils.js +244 -0
- package/esm/node_modules/json-schema-traverse/index.js +89 -0
- package/esm/node_modules/semver/classes/comparator.js +143 -0
- package/esm/node_modules/semver/classes/range.js +557 -0
- package/esm/node_modules/semver/classes/semver.js +333 -0
- package/esm/node_modules/semver/functions/clean.js +8 -0
- package/esm/node_modules/semver/functions/cmp.js +54 -0
- package/esm/node_modules/semver/functions/coerce.js +62 -0
- package/esm/node_modules/semver/functions/compare-build.js +9 -0
- package/esm/node_modules/semver/functions/compare-loose.js +5 -0
- package/esm/node_modules/semver/functions/compare.js +7 -0
- package/esm/node_modules/semver/functions/diff.js +60 -0
- package/esm/node_modules/semver/functions/eq.js +5 -0
- package/esm/node_modules/semver/functions/gt.js +5 -0
- package/esm/node_modules/semver/functions/gte.js +5 -0
- package/esm/node_modules/semver/functions/inc.js +21 -0
- package/esm/node_modules/semver/functions/lt.js +5 -0
- package/esm/node_modules/semver/functions/lte.js +5 -0
- package/esm/node_modules/semver/functions/major.js +5 -0
- package/esm/node_modules/semver/functions/minor.js +5 -0
- package/esm/node_modules/semver/functions/neq.js +5 -0
- package/esm/node_modules/semver/functions/parse.js +18 -0
- package/esm/node_modules/semver/functions/patch.js +5 -0
- package/esm/node_modules/semver/functions/prerelease.js +8 -0
- package/esm/node_modules/semver/functions/rcompare.js +5 -0
- package/esm/node_modules/semver/functions/rsort.js +5 -0
- package/esm/node_modules/semver/functions/satisfies.js +12 -0
- package/esm/node_modules/semver/functions/sort.js +5 -0
- package/esm/node_modules/semver/functions/valid.js +8 -0
- package/esm/node_modules/semver/index.js +91 -0
- package/esm/node_modules/semver/internal/constants.js +37 -0
- package/esm/node_modules/semver/internal/debug.js +11 -0
- package/esm/node_modules/semver/internal/identifiers.js +29 -0
- package/esm/node_modules/semver/internal/lrucache.js +42 -0
- package/esm/node_modules/semver/internal/parse-options.js +17 -0
- package/esm/node_modules/semver/internal/re.js +223 -0
- package/esm/node_modules/semver/ranges/gtr.js +6 -0
- package/esm/node_modules/semver/ranges/intersects.js +9 -0
- package/esm/node_modules/semver/ranges/ltr.js +6 -0
- package/esm/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/esm/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/esm/node_modules/semver/ranges/min-version.js +63 -0
- package/esm/node_modules/semver/ranges/outside.js +82 -0
- package/esm/node_modules/semver/ranges/simplify.js +49 -0
- package/esm/node_modules/semver/ranges/subset.js +249 -0
- package/esm/node_modules/semver/ranges/to-comparators.js +10 -0
- package/esm/node_modules/semver/ranges/valid.js +13 -0
- package/esm/util/fetch.ts.js +190 -0
- package/esm/util/index.ts.js +276 -0
- package/package.json +3 -4
- package/dist/main.css +0 -208
- package/dist/main.js +0 -17353
- /package/{dist/svg/iconcool.eb237688.svg → esm/assets/fonts/iconcool.svg} +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = require('./lib/utils.js')
|
|
4
|
+
const SCHEMES = require('./lib/schemes.js')
|
|
5
|
+
|
|
6
|
+
function normalize (uri, options) {
|
|
7
|
+
if (typeof uri === 'string') {
|
|
8
|
+
uri = serialize(parse(uri, options), options)
|
|
9
|
+
} else if (typeof uri === 'object') {
|
|
10
|
+
uri = parse(serialize(uri, options), options)
|
|
11
|
+
}
|
|
12
|
+
return uri
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function resolve (baseURI, relativeURI, options) {
|
|
16
|
+
const schemelessOptions = Object.assign({ scheme: 'null' }, options)
|
|
17
|
+
const resolved = resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true)
|
|
18
|
+
return serialize(resolved, { ...schemelessOptions, skipEscape: true })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function resolveComponents (base, relative, options, skipNormalization) {
|
|
22
|
+
const target = {}
|
|
23
|
+
if (!skipNormalization) {
|
|
24
|
+
base = parse(serialize(base, options), options) // normalize base components
|
|
25
|
+
relative = parse(serialize(relative, options), options) // normalize relative components
|
|
26
|
+
}
|
|
27
|
+
options = options || {}
|
|
28
|
+
|
|
29
|
+
if (!options.tolerant && relative.scheme) {
|
|
30
|
+
target.scheme = relative.scheme
|
|
31
|
+
// target.authority = relative.authority;
|
|
32
|
+
target.userinfo = relative.userinfo
|
|
33
|
+
target.host = relative.host
|
|
34
|
+
target.port = relative.port
|
|
35
|
+
target.path = removeDotSegments(relative.path || '')
|
|
36
|
+
target.query = relative.query
|
|
37
|
+
} else {
|
|
38
|
+
if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
|
|
39
|
+
// target.authority = relative.authority;
|
|
40
|
+
target.userinfo = relative.userinfo
|
|
41
|
+
target.host = relative.host
|
|
42
|
+
target.port = relative.port
|
|
43
|
+
target.path = removeDotSegments(relative.path || '')
|
|
44
|
+
target.query = relative.query
|
|
45
|
+
} else {
|
|
46
|
+
if (!relative.path) {
|
|
47
|
+
target.path = base.path
|
|
48
|
+
if (relative.query !== undefined) {
|
|
49
|
+
target.query = relative.query
|
|
50
|
+
} else {
|
|
51
|
+
target.query = base.query
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
if (relative.path.charAt(0) === '/') {
|
|
55
|
+
target.path = removeDotSegments(relative.path)
|
|
56
|
+
} else {
|
|
57
|
+
if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
|
|
58
|
+
target.path = '/' + relative.path
|
|
59
|
+
} else if (!base.path) {
|
|
60
|
+
target.path = relative.path
|
|
61
|
+
} else {
|
|
62
|
+
target.path = base.path.slice(0, base.path.lastIndexOf('/') + 1) + relative.path
|
|
63
|
+
}
|
|
64
|
+
target.path = removeDotSegments(target.path)
|
|
65
|
+
}
|
|
66
|
+
target.query = relative.query
|
|
67
|
+
}
|
|
68
|
+
// target.authority = base.authority;
|
|
69
|
+
target.userinfo = base.userinfo
|
|
70
|
+
target.host = base.host
|
|
71
|
+
target.port = base.port
|
|
72
|
+
}
|
|
73
|
+
target.scheme = base.scheme
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
target.fragment = relative.fragment
|
|
77
|
+
|
|
78
|
+
return target
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function equal (uriA, uriB, options) {
|
|
82
|
+
if (typeof uriA === 'string') {
|
|
83
|
+
uriA = unescape(uriA)
|
|
84
|
+
uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), { ...options, skipEscape: true })
|
|
85
|
+
} else if (typeof uriA === 'object') {
|
|
86
|
+
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true })
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof uriB === 'string') {
|
|
90
|
+
uriB = unescape(uriB)
|
|
91
|
+
uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), { ...options, skipEscape: true })
|
|
92
|
+
} else if (typeof uriB === 'object') {
|
|
93
|
+
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true })
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return uriA.toLowerCase() === uriB.toLowerCase()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function serialize (cmpts, opts) {
|
|
100
|
+
const components = {
|
|
101
|
+
host: cmpts.host,
|
|
102
|
+
scheme: cmpts.scheme,
|
|
103
|
+
userinfo: cmpts.userinfo,
|
|
104
|
+
port: cmpts.port,
|
|
105
|
+
path: cmpts.path,
|
|
106
|
+
query: cmpts.query,
|
|
107
|
+
nid: cmpts.nid,
|
|
108
|
+
nss: cmpts.nss,
|
|
109
|
+
uuid: cmpts.uuid,
|
|
110
|
+
fragment: cmpts.fragment,
|
|
111
|
+
reference: cmpts.reference,
|
|
112
|
+
resourceName: cmpts.resourceName,
|
|
113
|
+
secure: cmpts.secure,
|
|
114
|
+
error: ''
|
|
115
|
+
}
|
|
116
|
+
const options = Object.assign({}, opts)
|
|
117
|
+
const uriTokens = []
|
|
118
|
+
|
|
119
|
+
// find scheme handler
|
|
120
|
+
const schemeHandler = SCHEMES[(options.scheme || components.scheme || '').toLowerCase()]
|
|
121
|
+
|
|
122
|
+
// perform scheme specific serialization
|
|
123
|
+
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options)
|
|
124
|
+
|
|
125
|
+
if (components.path !== undefined) {
|
|
126
|
+
if (!options.skipEscape) {
|
|
127
|
+
components.path = escape(components.path)
|
|
128
|
+
|
|
129
|
+
if (components.scheme !== undefined) {
|
|
130
|
+
components.path = components.path.split('%3A').join(':')
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
components.path = unescape(components.path)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (options.reference !== 'suffix' && components.scheme) {
|
|
138
|
+
uriTokens.push(components.scheme, ':')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const authority = recomposeAuthority(components)
|
|
142
|
+
if (authority !== undefined) {
|
|
143
|
+
if (options.reference !== 'suffix') {
|
|
144
|
+
uriTokens.push('//')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
uriTokens.push(authority)
|
|
148
|
+
|
|
149
|
+
if (components.path && components.path.charAt(0) !== '/') {
|
|
150
|
+
uriTokens.push('/')
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (components.path !== undefined) {
|
|
154
|
+
let s = components.path
|
|
155
|
+
|
|
156
|
+
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
157
|
+
s = removeDotSegments(s)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (authority === undefined) {
|
|
161
|
+
s = s.replace(/^\/\//u, '/%2F') // don't allow the path to start with "//"
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
uriTokens.push(s)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (components.query !== undefined) {
|
|
168
|
+
uriTokens.push('?', components.query)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (components.fragment !== undefined) {
|
|
172
|
+
uriTokens.push('#', components.fragment)
|
|
173
|
+
}
|
|
174
|
+
return uriTokens.join('')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)))
|
|
178
|
+
|
|
179
|
+
function nonSimpleDomain (value) {
|
|
180
|
+
let code = 0
|
|
181
|
+
for (let i = 0, len = value.length; i < len; ++i) {
|
|
182
|
+
code = value.charCodeAt(i)
|
|
183
|
+
if (code > 126 || hexLookUp[code]) {
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return false
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u
|
|
191
|
+
|
|
192
|
+
function parse (uri, opts) {
|
|
193
|
+
const options = Object.assign({}, opts)
|
|
194
|
+
const parsed = {
|
|
195
|
+
scheme: undefined,
|
|
196
|
+
userinfo: undefined,
|
|
197
|
+
host: '',
|
|
198
|
+
port: undefined,
|
|
199
|
+
path: '',
|
|
200
|
+
query: undefined,
|
|
201
|
+
fragment: undefined
|
|
202
|
+
}
|
|
203
|
+
const gotEncoding = uri.indexOf('%') !== -1
|
|
204
|
+
let isIP = false
|
|
205
|
+
if (options.reference === 'suffix') uri = (options.scheme ? options.scheme + ':' : '') + '//' + uri
|
|
206
|
+
|
|
207
|
+
const matches = uri.match(URI_PARSE)
|
|
208
|
+
|
|
209
|
+
if (matches) {
|
|
210
|
+
// store each component
|
|
211
|
+
parsed.scheme = matches[1]
|
|
212
|
+
parsed.userinfo = matches[3]
|
|
213
|
+
parsed.host = matches[4]
|
|
214
|
+
parsed.port = parseInt(matches[5], 10)
|
|
215
|
+
parsed.path = matches[6] || ''
|
|
216
|
+
parsed.query = matches[7]
|
|
217
|
+
parsed.fragment = matches[8]
|
|
218
|
+
|
|
219
|
+
// fix port number
|
|
220
|
+
if (isNaN(parsed.port)) {
|
|
221
|
+
parsed.port = matches[5]
|
|
222
|
+
}
|
|
223
|
+
if (parsed.host) {
|
|
224
|
+
const ipv4result = normalizeIPv4(parsed.host)
|
|
225
|
+
if (ipv4result.isIPV4 === false) {
|
|
226
|
+
const ipv6result = normalizeIPv6(ipv4result.host)
|
|
227
|
+
parsed.host = ipv6result.host.toLowerCase()
|
|
228
|
+
isIP = ipv6result.isIPV6
|
|
229
|
+
} else {
|
|
230
|
+
parsed.host = ipv4result.host
|
|
231
|
+
isIP = true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (parsed.scheme === undefined && parsed.userinfo === undefined && parsed.host === undefined && parsed.port === undefined && parsed.query === undefined && !parsed.path) {
|
|
235
|
+
parsed.reference = 'same-document'
|
|
236
|
+
} else if (parsed.scheme === undefined) {
|
|
237
|
+
parsed.reference = 'relative'
|
|
238
|
+
} else if (parsed.fragment === undefined) {
|
|
239
|
+
parsed.reference = 'absolute'
|
|
240
|
+
} else {
|
|
241
|
+
parsed.reference = 'uri'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// check for reference errors
|
|
245
|
+
if (options.reference && options.reference !== 'suffix' && options.reference !== parsed.reference) {
|
|
246
|
+
parsed.error = parsed.error || 'URI is not a ' + options.reference + ' reference.'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// find scheme handler
|
|
250
|
+
const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || '').toLowerCase()]
|
|
251
|
+
|
|
252
|
+
// check if scheme can't handle IRIs
|
|
253
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
254
|
+
// if host component is a domain name
|
|
255
|
+
if (parsed.host && (options.domainHost || (schemeHandler && schemeHandler.domainHost)) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
256
|
+
// convert Unicode IDN -> ASCII IDN
|
|
257
|
+
try {
|
|
258
|
+
parsed.host = URL.domainToASCII(parsed.host.toLowerCase())
|
|
259
|
+
} catch (e) {
|
|
260
|
+
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// convert IRI -> URI
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!schemeHandler || (schemeHandler && !schemeHandler.skipNormalize)) {
|
|
267
|
+
if (gotEncoding && parsed.scheme !== undefined) {
|
|
268
|
+
parsed.scheme = unescape(parsed.scheme)
|
|
269
|
+
}
|
|
270
|
+
if (gotEncoding && parsed.host !== undefined) {
|
|
271
|
+
parsed.host = unescape(parsed.host)
|
|
272
|
+
}
|
|
273
|
+
if (parsed.path) {
|
|
274
|
+
parsed.path = escape(unescape(parsed.path))
|
|
275
|
+
}
|
|
276
|
+
if (parsed.fragment) {
|
|
277
|
+
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment))
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// perform scheme specific parsing
|
|
282
|
+
if (schemeHandler && schemeHandler.parse) {
|
|
283
|
+
schemeHandler.parse(parsed, options)
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
parsed.error = parsed.error || 'URI can not be parsed.'
|
|
287
|
+
}
|
|
288
|
+
return parsed
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const fastUri = {
|
|
292
|
+
SCHEMES,
|
|
293
|
+
normalize,
|
|
294
|
+
resolve,
|
|
295
|
+
resolveComponents,
|
|
296
|
+
equal,
|
|
297
|
+
serialize,
|
|
298
|
+
parse
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
module.exports = fastUri
|
|
302
|
+
module.exports.default = fastUri
|
|
303
|
+
module.exports.fastUri = fastUri
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const UUID_REG = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu
|
|
4
|
+
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu
|
|
5
|
+
|
|
6
|
+
function isSecure (wsComponents) {
|
|
7
|
+
return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === 'wss'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function httpParse (components) {
|
|
11
|
+
if (!components.host) {
|
|
12
|
+
components.error = components.error || 'HTTP URIs must have a host.'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return components
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function httpSerialize (components) {
|
|
19
|
+
const secure = String(components.scheme).toLowerCase() === 'https'
|
|
20
|
+
|
|
21
|
+
// normalize the default port
|
|
22
|
+
if (components.port === (secure ? 443 : 80) || components.port === '') {
|
|
23
|
+
components.port = undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// normalize the empty path
|
|
27
|
+
if (!components.path) {
|
|
28
|
+
components.path = '/'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// NOTE: We do not parse query strings for HTTP URIs
|
|
32
|
+
// as WWW Form Url Encoded query strings are part of the HTML4+ spec,
|
|
33
|
+
// and not the HTTP spec.
|
|
34
|
+
|
|
35
|
+
return components
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function wsParse (wsComponents) {
|
|
39
|
+
// indicate if the secure flag is set
|
|
40
|
+
wsComponents.secure = isSecure(wsComponents)
|
|
41
|
+
|
|
42
|
+
// construct resouce name
|
|
43
|
+
wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '')
|
|
44
|
+
wsComponents.path = undefined
|
|
45
|
+
wsComponents.query = undefined
|
|
46
|
+
|
|
47
|
+
return wsComponents
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function wsSerialize (wsComponents) {
|
|
51
|
+
// normalize the default port
|
|
52
|
+
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === '') {
|
|
53
|
+
wsComponents.port = undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ensure scheme matches secure flag
|
|
57
|
+
if (typeof wsComponents.secure === 'boolean') {
|
|
58
|
+
wsComponents.scheme = (wsComponents.secure ? 'wss' : 'ws')
|
|
59
|
+
wsComponents.secure = undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// reconstruct path from resource name
|
|
63
|
+
if (wsComponents.resourceName) {
|
|
64
|
+
const [path, query] = wsComponents.resourceName.split('?')
|
|
65
|
+
wsComponents.path = (path && path !== '/' ? path : undefined)
|
|
66
|
+
wsComponents.query = query
|
|
67
|
+
wsComponents.resourceName = undefined
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// forbid fragment component
|
|
71
|
+
wsComponents.fragment = undefined
|
|
72
|
+
|
|
73
|
+
return wsComponents
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function urnParse (urnComponents, options) {
|
|
77
|
+
if (!urnComponents.path) {
|
|
78
|
+
urnComponents.error = 'URN can not be parsed'
|
|
79
|
+
return urnComponents
|
|
80
|
+
}
|
|
81
|
+
const matches = urnComponents.path.match(URN_REG)
|
|
82
|
+
if (matches) {
|
|
83
|
+
const scheme = options.scheme || urnComponents.scheme || 'urn'
|
|
84
|
+
urnComponents.nid = matches[1].toLowerCase()
|
|
85
|
+
urnComponents.nss = matches[2]
|
|
86
|
+
const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`
|
|
87
|
+
const schemeHandler = SCHEMES[urnScheme]
|
|
88
|
+
urnComponents.path = undefined
|
|
89
|
+
|
|
90
|
+
if (schemeHandler) {
|
|
91
|
+
urnComponents = schemeHandler.parse(urnComponents, options)
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
urnComponents.error = urnComponents.error || 'URN can not be parsed.'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return urnComponents
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function urnSerialize (urnComponents, options) {
|
|
101
|
+
const scheme = options.scheme || urnComponents.scheme || 'urn'
|
|
102
|
+
const nid = urnComponents.nid.toLowerCase()
|
|
103
|
+
const urnScheme = `${scheme}:${options.nid || nid}`
|
|
104
|
+
const schemeHandler = SCHEMES[urnScheme]
|
|
105
|
+
|
|
106
|
+
if (schemeHandler) {
|
|
107
|
+
urnComponents = schemeHandler.serialize(urnComponents, options)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const uriComponents = urnComponents
|
|
111
|
+
const nss = urnComponents.nss
|
|
112
|
+
uriComponents.path = `${nid || options.nid}:${nss}`
|
|
113
|
+
|
|
114
|
+
options.skipEscape = true
|
|
115
|
+
return uriComponents
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function urnuuidParse (urnComponents, options) {
|
|
119
|
+
const uuidComponents = urnComponents
|
|
120
|
+
uuidComponents.uuid = uuidComponents.nss
|
|
121
|
+
uuidComponents.nss = undefined
|
|
122
|
+
|
|
123
|
+
if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
|
|
124
|
+
uuidComponents.error = uuidComponents.error || 'UUID is not valid.'
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return uuidComponents
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function urnuuidSerialize (uuidComponents) {
|
|
131
|
+
const urnComponents = uuidComponents
|
|
132
|
+
// normalize UUID
|
|
133
|
+
urnComponents.nss = (uuidComponents.uuid || '').toLowerCase()
|
|
134
|
+
return urnComponents
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const http = {
|
|
138
|
+
scheme: 'http',
|
|
139
|
+
domainHost: true,
|
|
140
|
+
parse: httpParse,
|
|
141
|
+
serialize: httpSerialize
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const https = {
|
|
145
|
+
scheme: 'https',
|
|
146
|
+
domainHost: http.domainHost,
|
|
147
|
+
parse: httpParse,
|
|
148
|
+
serialize: httpSerialize
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const ws = {
|
|
152
|
+
scheme: 'ws',
|
|
153
|
+
domainHost: true,
|
|
154
|
+
parse: wsParse,
|
|
155
|
+
serialize: wsSerialize
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const wss = {
|
|
159
|
+
scheme: 'wss',
|
|
160
|
+
domainHost: ws.domainHost,
|
|
161
|
+
parse: ws.parse,
|
|
162
|
+
serialize: ws.serialize
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const urn = {
|
|
166
|
+
scheme: 'urn',
|
|
167
|
+
parse: urnParse,
|
|
168
|
+
serialize: urnSerialize,
|
|
169
|
+
skipNormalize: true
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const urnuuid = {
|
|
173
|
+
scheme: 'urn:uuid',
|
|
174
|
+
parse: urnuuidParse,
|
|
175
|
+
serialize: urnuuidSerialize,
|
|
176
|
+
skipNormalize: true
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const SCHEMES = {
|
|
180
|
+
http,
|
|
181
|
+
https,
|
|
182
|
+
ws,
|
|
183
|
+
wss,
|
|
184
|
+
urn,
|
|
185
|
+
'urn:uuid': urnuuid
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
module.exports = SCHEMES
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const HEX = {
|
|
4
|
+
0: 0,
|
|
5
|
+
1: 1,
|
|
6
|
+
2: 2,
|
|
7
|
+
3: 3,
|
|
8
|
+
4: 4,
|
|
9
|
+
5: 5,
|
|
10
|
+
6: 6,
|
|
11
|
+
7: 7,
|
|
12
|
+
8: 8,
|
|
13
|
+
9: 9,
|
|
14
|
+
a: 10,
|
|
15
|
+
A: 10,
|
|
16
|
+
b: 11,
|
|
17
|
+
B: 11,
|
|
18
|
+
c: 12,
|
|
19
|
+
C: 12,
|
|
20
|
+
d: 13,
|
|
21
|
+
D: 13,
|
|
22
|
+
e: 14,
|
|
23
|
+
E: 14,
|
|
24
|
+
f: 15,
|
|
25
|
+
F: 15
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
HEX
|
|
30
|
+
}
|