@blueking/bkui-form 1.0.1-beta.3 → 1.0.1-beta.5
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/dist/adapter/common/FieldGroupWrap.d.ts +209 -0
- package/dist/adapter/field/ArrayField.d.ts +147 -0
- package/dist/adapter/field/BooleanField.d.ts +145 -0
- package/dist/adapter/field/CompositionField.d.ts +151 -0
- package/dist/adapter/field/FieldProps.d.ts +70 -0
- package/dist/adapter/field/NumberField.d.ts +145 -0
- package/dist/adapter/field/ObjectField.d.ts +147 -0
- package/dist/adapter/field/SchemaField.d.ts +145 -0
- package/dist/adapter/field/StringField.d.ts +4 -0
- package/dist/adapter/widget/ArrayWidget.d.ts +154 -0
- package/dist/adapter/widget/ButtonWidget.d.ts +16 -0
- package/dist/adapter/widget/CheckboxWidget.d.ts +34 -0
- package/dist/adapter/widget/CollapseGroupWidget.d.ts +196 -0
- package/dist/adapter/widget/ColorPickerWidget.d.ts +8 -0
- package/dist/adapter/widget/InputWidget.d.ts +30 -0
- package/dist/adapter/widget/KeyValueArrayWidget.d.ts +157 -0
- package/dist/adapter/widget/RadioWidget.d.ts +37 -0
- package/dist/adapter/widget/SelectWidget.d.ts +37 -0
- package/dist/adapter/widget/SwitchWidget.d.ts +10 -0
- package/dist/adapter/widget/TabGroupWidget.d.ts +187 -0
- package/dist/adapter/widget/TableWidget.d.ts +154 -0
- package/dist/adapter/widget/Widget.d.ts +182 -0
- package/dist/controller/form.d.ts +141 -0
- package/dist/controller/props.d.ts +62 -0
- package/dist/core/events.d.ts +10 -0
- package/dist/core/expression.d.ts +13 -0
- package/dist/core/form.d.ts +5 -0
- package/dist/core/lang.d.ts +1 -0
- package/dist/core/layout.d.ts +20 -0
- package/dist/core/lifecycle.d.ts +0 -0
- package/dist/core/path.d.ts +9 -0
- package/dist/core/proxy.d.ts +3 -0
- package/dist/core/reaction.d.ts +5 -0
- package/dist/core/register.d.ts +19 -0
- package/dist/core/schema.d.ts +26 -0
- package/dist/core/validator.d.ts +35 -0
- package/dist/core/widgetTree.d.ts +40 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +7443 -0
- package/dist/index.umd.js +12 -0
- package/dist/style.css +1 -0
- package/dist/util/fetch.d.ts +10 -0
- package/dist/util/index.d.ts +23 -0
- package/package.json +24 -12
- package/esm/adapter/common/FieldGroupWrap.tsx.js +0 -199
- package/esm/adapter/field/ArrayField.tsx.js +0 -55
- package/esm/adapter/field/BooleanField.tsx.js +0 -41
- package/esm/adapter/field/CompositionField.tsx.js +0 -113
- package/esm/adapter/field/FieldProps.ts.js +0 -85
- package/esm/adapter/field/NumberField.tsx.js +0 -19
- package/esm/adapter/field/ObjectField.tsx.js +0 -58
- package/esm/adapter/field/SchemaField.tsx.js +0 -28
- package/esm/adapter/field/StringField.tsx.js +0 -4
- package/esm/adapter/widget/ArrayWidget.ts.js +0 -196
- package/esm/adapter/widget/ButtonWidget.ts.js +0 -76
- package/esm/adapter/widget/CheckboxWidget.ts.js +0 -101
- package/esm/adapter/widget/CollapseGroupWidget.ts.js +0 -140
- package/esm/adapter/widget/ColorPickerWidget.ts.js +0 -71
- package/esm/adapter/widget/InputWidget.ts.js +0 -79
- package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +0 -156
- package/esm/adapter/widget/RadioWidget.ts.js +0 -98
- package/esm/adapter/widget/SelectWidget.ts.js +0 -98
- package/esm/adapter/widget/SwitchWidget.ts.js +0 -73
- package/esm/adapter/widget/TabGroupWidget.ts.js +0 -145
- package/esm/adapter/widget/TableWidget.ts.js +0 -205
- package/esm/adapter/widget/Widget.ts.js +0 -497
- package/esm/assets/fonts/iconcool.eot +0 -0
- package/esm/assets/fonts/iconcool.svg +0 -53
- package/esm/assets/fonts/iconcool.ttf +0 -0
- package/esm/assets/fonts/iconcool.woff +0 -0
- package/esm/assets/style.css +0 -43
- package/esm/controller/form.css +0 -164
- package/esm/controller/form.tsx.js +0 -159
- package/esm/controller/props.ts.js +0 -75
- package/esm/core/events.ts.js +0 -74
- package/esm/core/expression.ts.js +0 -67
- package/esm/core/lang.ts.js +0 -25
- package/esm/core/layout.ts.js +0 -149
- package/esm/core/path.ts.js +0 -60
- package/esm/core/proxy.ts.js +0 -10
- package/esm/core/reaction.ts.js +0 -116
- package/esm/core/register.ts.js +0 -74
- package/esm/core/schema.ts.js +0 -302
- package/esm/core/validator.ts.js +0 -248
- package/esm/core/widgetTree.ts.js +0 -163
- package/esm/index.ts.js +0 -6
- package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +0 -35
- package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +0 -233
- package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +0 -172
- package/esm/node_modules/ajv/dist/ajv.js +0 -50
- package/esm/node_modules/ajv/dist/compile/codegen/code.js +0 -156
- package/esm/node_modules/ajv/dist/compile/codegen/index.js +0 -697
- package/esm/node_modules/ajv/dist/compile/codegen/scope.js +0 -143
- package/esm/node_modules/ajv/dist/compile/errors.js +0 -123
- package/esm/node_modules/ajv/dist/compile/index.js +0 -242
- package/esm/node_modules/ajv/dist/compile/names.js +0 -28
- package/esm/node_modules/ajv/dist/compile/ref_error.js +0 -12
- package/esm/node_modules/ajv/dist/compile/resolve.js +0 -155
- package/esm/node_modules/ajv/dist/compile/rules.js +0 -26
- package/esm/node_modules/ajv/dist/compile/util.js +0 -178
- package/esm/node_modules/ajv/dist/compile/validate/applicability.js +0 -19
- package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -50
- package/esm/node_modules/ajv/dist/compile/validate/dataType.js +0 -203
- package/esm/node_modules/ajv/dist/compile/validate/defaults.js +0 -35
- package/esm/node_modules/ajv/dist/compile/validate/index.js +0 -520
- package/esm/node_modules/ajv/dist/compile/validate/keyword.js +0 -124
- package/esm/node_modules/ajv/dist/compile/validate/subschema.js +0 -81
- package/esm/node_modules/ajv/dist/core.js +0 -618
- package/esm/node_modules/ajv/dist/refs/data.json +0 -13
- package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +0 -151
- package/esm/node_modules/ajv/dist/runtime/equal.js +0 -7
- package/esm/node_modules/ajv/dist/runtime/ucs2length.js +0 -24
- package/esm/node_modules/ajv/dist/runtime/uri.js +0 -6
- package/esm/node_modules/ajv/dist/runtime/validation_error.js +0 -11
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -49
- package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -106
- package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -23
- package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -12
- package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -95
- package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -85
- package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -66
- package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -44
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -52
- package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -30
- package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -26
- package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -60
- package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -75
- package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -12
- package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -54
- package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -38
- package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -13
- package/esm/node_modules/ajv/dist/vocabularies/code.js +0 -131
- package/esm/node_modules/ajv/dist/vocabularies/core/id.js +0 -10
- package/esm/node_modules/ajv/dist/vocabularies/core/index.js +0 -16
- package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +0 -122
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -104
- package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -9
- package/esm/node_modules/ajv/dist/vocabularies/draft7.js +0 -17
- package/esm/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
- package/esm/node_modules/ajv/dist/vocabularies/format/index.js +0 -6
- package/esm/node_modules/ajv/dist/vocabularies/metadata.js +0 -18
- package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +0 -25
- package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -48
- package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +0 -33
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -24
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -27
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -27
- package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -24
- package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -26
- package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -24
- package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +0 -79
- package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -64
- package/esm/node_modules/ajv-formats/dist/formats.js +0 -173
- package/esm/node_modules/ajv-formats/dist/index.js +0 -37
- package/esm/node_modules/ajv-formats/dist/limit.js +0 -69
- package/esm/node_modules/ajv-i18n/localize/zh/index.js +0 -154
- package/esm/node_modules/fast-deep-equal/index.js +0 -46
- package/esm/node_modules/fast-uri/index.js +0 -303
- package/esm/node_modules/fast-uri/lib/schemes.js +0 -188
- package/esm/node_modules/fast-uri/lib/scopedChars.js +0 -30
- package/esm/node_modules/fast-uri/lib/utils.js +0 -244
- package/esm/node_modules/json-schema-traverse/index.js +0 -89
- package/esm/node_modules/semver/classes/comparator.js +0 -143
- package/esm/node_modules/semver/classes/range.js +0 -557
- package/esm/node_modules/semver/classes/semver.js +0 -333
- package/esm/node_modules/semver/functions/clean.js +0 -8
- package/esm/node_modules/semver/functions/cmp.js +0 -54
- package/esm/node_modules/semver/functions/coerce.js +0 -62
- package/esm/node_modules/semver/functions/compare-build.js +0 -9
- package/esm/node_modules/semver/functions/compare-loose.js +0 -5
- package/esm/node_modules/semver/functions/compare.js +0 -7
- package/esm/node_modules/semver/functions/diff.js +0 -60
- package/esm/node_modules/semver/functions/eq.js +0 -5
- package/esm/node_modules/semver/functions/gt.js +0 -5
- package/esm/node_modules/semver/functions/gte.js +0 -5
- package/esm/node_modules/semver/functions/inc.js +0 -21
- package/esm/node_modules/semver/functions/lt.js +0 -5
- package/esm/node_modules/semver/functions/lte.js +0 -5
- package/esm/node_modules/semver/functions/major.js +0 -5
- package/esm/node_modules/semver/functions/minor.js +0 -5
- package/esm/node_modules/semver/functions/neq.js +0 -5
- package/esm/node_modules/semver/functions/parse.js +0 -18
- package/esm/node_modules/semver/functions/patch.js +0 -5
- package/esm/node_modules/semver/functions/prerelease.js +0 -8
- package/esm/node_modules/semver/functions/rcompare.js +0 -5
- package/esm/node_modules/semver/functions/rsort.js +0 -5
- package/esm/node_modules/semver/functions/satisfies.js +0 -12
- package/esm/node_modules/semver/functions/sort.js +0 -5
- package/esm/node_modules/semver/functions/valid.js +0 -8
- package/esm/node_modules/semver/index.js +0 -91
- package/esm/node_modules/semver/internal/constants.js +0 -37
- package/esm/node_modules/semver/internal/debug.js +0 -11
- package/esm/node_modules/semver/internal/identifiers.js +0 -29
- package/esm/node_modules/semver/internal/lrucache.js +0 -42
- package/esm/node_modules/semver/internal/parse-options.js +0 -17
- package/esm/node_modules/semver/internal/re.js +0 -223
- package/esm/node_modules/semver/ranges/gtr.js +0 -6
- package/esm/node_modules/semver/ranges/intersects.js +0 -9
- package/esm/node_modules/semver/ranges/ltr.js +0 -6
- package/esm/node_modules/semver/ranges/max-satisfying.js +0 -27
- package/esm/node_modules/semver/ranges/min-satisfying.js +0 -26
- package/esm/node_modules/semver/ranges/min-version.js +0 -63
- package/esm/node_modules/semver/ranges/outside.js +0 -82
- package/esm/node_modules/semver/ranges/simplify.js +0 -49
- package/esm/node_modules/semver/ranges/subset.js +0 -249
- package/esm/node_modules/semver/ranges/to-comparators.js +0 -10
- package/esm/node_modules/semver/ranges/valid.js +0 -13
- package/esm/util/fetch.ts.js +0 -190
- package/esm/util/index.ts.js +0 -276
|
@@ -1,303 +0,0 @@
|
|
|
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
|
|
@@ -1,188 +0,0 @@
|
|
|
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
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
}
|