@cyclonedx/cyclonedx-library 1.3.2 → 1.4.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/README.md +1 -1
- package/dist.node/factories/fromNodePackageJson.node.js +40 -1
- package/dist.node/factories/fromNodePackageJson.node.js.map +1 -1
- package/dist.node/factories/index.node.js.map +1 -1
- package/dist.node/factories/packageUrl.js +14 -5
- package/dist.node/factories/packageUrl.js.map +1 -1
- package/dist.node/helpers/packageUrl.js +28 -0
- package/dist.node/helpers/packageUrl.js.map +1 -0
- package/dist.node/serialize/json/normalize.js +1 -1
- package/dist.node/serialize/json/normalize.js.map +1 -1
- package/dist.node/serialize/xml/types.js +25 -3
- package/dist.node/serialize/xml/types.js.map +1 -1
- package/dist.web/lib.dev.js +77 -9
- package/dist.web/lib.dev.js.map +1 -1
- package/dist.web/lib.js +1 -1
- package/package.json +9 -6
- package/src/factories/fromNodePackageJson.node.ts +54 -0
- package/src/factories/index.node.ts +1 -0
- package/src/factories/packageUrl.ts +23 -8
- package/src/helpers/packageUrl.ts +29 -0
- package/src/serialize/json/normalize.ts +1 -1
- package/src/serialize/xml/types.ts +36 -5
|
@@ -20,6 +20,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
|
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
21
21
|
export namespace XmlSchema {
|
|
22
22
|
|
|
23
|
+
const _anyUriSchemePattern = /^[a-z][a-z0-9+\-.]*$/i
|
|
24
|
+
|
|
23
25
|
/**
|
|
24
26
|
* @see isAnyURI
|
|
25
27
|
*/
|
|
@@ -28,13 +30,42 @@ export namespace XmlSchema {
|
|
|
28
30
|
* Test whether format is XML::anyURI - best-effort.
|
|
29
31
|
*
|
|
30
32
|
* @see {@link http://www.w3.org/TR/xmlschema-2/#anyURI}
|
|
31
|
-
* @see {@link
|
|
33
|
+
* @see {@link https://www.w3.org/2011/04/XMLSchema/TypeLibrary-URI-RFC3986.xsd}
|
|
34
|
+
* @see {@link https://www.w3.org/2011/04/XMLSchema/TypeLibrary-IRI-RFC3987.xsd}
|
|
32
35
|
*/
|
|
33
36
|
export function isAnyURI (value: AnyURI | any): value is AnyURI {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (typeof value !== 'string') {
|
|
38
|
+
// not a string
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
if (value.length === 0) {
|
|
42
|
+
// empty string
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const fragmentPos = value.indexOf('#')
|
|
47
|
+
let beforeFragment: string
|
|
48
|
+
if (fragmentPos >= 0) {
|
|
49
|
+
if (value.includes('#', fragmentPos + 1)) {
|
|
50
|
+
// has a second fragment marker
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
beforeFragment = value.slice(undefined, fragmentPos)
|
|
54
|
+
} else {
|
|
55
|
+
beforeFragment = value
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const schemePos = beforeFragment.indexOf(':')
|
|
59
|
+
if (schemePos >= 0) {
|
|
60
|
+
if (!_anyUriSchemePattern.test(beforeFragment.slice(undefined, schemePos))) {
|
|
61
|
+
// invalid schema
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// @TODO add more validation according to spec
|
|
67
|
+
|
|
68
|
+
return true
|
|
38
69
|
}
|
|
39
70
|
|
|
40
71
|
}
|