@scaleway/regex 5.0.1 → 5.1.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/CHANGELOG.md +6 -0
- package/dist/index.js +108 -57
- package/package.json +5 -2
- package/vite.config.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1960](https://github.com/scaleway/scaleway-lib/pull/1960) [`d034b3c`](https://github.com/scaleway/scaleway-lib/commit/d034b3cda1cac30ce2ed4e95be5a2c79642f8ca4) Thanks [@Slashgear](https://github.com/Slashgear)! - add legacy main attribut for CommonJS export usage
|
|
8
|
+
|
|
3
9
|
## 5.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,112 @@
|
|
|
1
|
-
const
|
|
1
|
+
const accessKeyRegex = /^SCW[A-Z0-9]{17}$/i;
|
|
2
|
+
const alpha = /^[a-zA-Z]*$/;
|
|
3
|
+
const alphaLowercase = /^[a-z]+$/;
|
|
4
|
+
const alphanum = /^[a-zA-Z0-9]*$/;
|
|
5
|
+
const alphaDashes = /^[a-zA-Z-]*$/;
|
|
6
|
+
const alphanumDash = /^[a-zA-Z0-9-]*$/;
|
|
7
|
+
const alphanumDashDots = /^[a-zA-Z0-9-.]*$/;
|
|
8
|
+
const alphanumDashDotsOrEmpty = /^$|^[a-zA-Z0-9-.]*$/;
|
|
9
|
+
const alphanumDashDotsSpaces = /^[a-zA-Z0-9-.\s]*$/;
|
|
10
|
+
const alphanumDashLowercase = /^[a-z0-9-]+$/;
|
|
11
|
+
const alphanumDashSpaces = /^[a-zA-Z0-9-\s]*$/;
|
|
12
|
+
const alphanumDashOrEmpty = /^$|^[a-zA-Z0-9-]*$/;
|
|
13
|
+
const alphanumDashUnderscoreDots = /^[a-zA-Z0-9-._]*$/;
|
|
14
|
+
const alphanumDashUnderscore = /^[a-zA-Z0-9-_]*$/;
|
|
15
|
+
const alphanumDashUnderscoreDotsSpacesParenthesis = /^[a-zA-Z0-9-_.()\s]*$/;
|
|
16
|
+
const alphanumDashUnderscoreDotsSpaces = /^[a-zA-Z0-9-.\s_]*$/;
|
|
17
|
+
const alphanumDashUnderscoreDollar = /^[a-zA-Z0-9_$-]*$/;
|
|
18
|
+
const alphanumDots = /^[a-zA-Z0-9.]*$/;
|
|
19
|
+
const alphanumLowercase = /^[a-z0-9]+$/;
|
|
20
|
+
const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/;
|
|
21
|
+
const ascii = /^[\x00-\x7F]+$/;
|
|
22
|
+
const backupKey = /^[A-Z0-9]{32}$/;
|
|
23
|
+
const basicDomain = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+$/;
|
|
24
|
+
const uppercaseBasicDomain = /^(?![-])+[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/;
|
|
25
|
+
const uppercaseBasicSubdomain = /^(?![-])+[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,63})+$/;
|
|
26
|
+
const advancedDomainName = /^(?:(?:(?:[a-zA-Z0-9À-ÖØ-öø-ÿ](?:[a-zA-Z0-9À-ÖØ-öø-ÿ-]{0,61}[a-zA-Z0-9À-ÖØ-öø-ÿ])?)\.)+[a-zA-Z]{2,}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})(?::[\d]{1,5})?$/;
|
|
27
|
+
const cron = /^((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,7})$/;
|
|
28
|
+
const digits = /^[0-9]*$/;
|
|
29
|
+
const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
|
|
30
|
+
const email = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
|
31
|
+
const fourDigitsCode = /^[0-9]{4}$/;
|
|
32
|
+
const phone = /^\+[0-9]*/;
|
|
33
|
+
const spaces = /^\s*$/;
|
|
34
|
+
const sixDigitsCode = /^[0-9]{6}$/;
|
|
35
|
+
const url = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
|
|
36
|
+
const hexadecimal = /^[0-9a-fA-F]+$/;
|
|
37
|
+
const s3BucketName = /^[a-z0-9][-.a-z0-9]{1,61}[a-z0-9]$/;
|
|
38
|
+
const v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
|
|
39
|
+
const v6segment = "[a-fA-F\\d]{1,4}";
|
|
40
|
+
const v6 = `
|
|
2
41
|
(?:
|
|
3
|
-
(?:${
|
|
4
|
-
(?:${
|
|
5
|
-
(?:${
|
|
6
|
-
(?:${
|
|
7
|
-
(?:${
|
|
8
|
-
(?:${
|
|
9
|
-
(?:${
|
|
10
|
-
(?::(?:(?::${
|
|
42
|
+
(?:${v6segment}:){7}(?:${v6segment}|:)|
|
|
43
|
+
(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)|
|
|
44
|
+
(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)|
|
|
45
|
+
(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)|
|
|
46
|
+
(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)|
|
|
47
|
+
(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)|
|
|
48
|
+
(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)|
|
|
49
|
+
(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:))
|
|
11
50
|
)(?:%[0-9a-zA-Z]{1,})?
|
|
12
|
-
`.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim()
|
|
51
|
+
`.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
|
|
52
|
+
const cidrv4 = `${v4}\\/(3[0-2]|[12]?[0-9])`;
|
|
53
|
+
const cidrv6 = `${v6}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;
|
|
54
|
+
const ip = new RegExp(`^(?:${v4}|${v6})$`);
|
|
55
|
+
const ipv4 = new RegExp(`^${v4}$`);
|
|
56
|
+
const ipv6 = new RegExp(`^${v6}$`);
|
|
57
|
+
const ipCidr = new RegExp(`(?:^${cidrv4}$)|(?:^${cidrv6}$)`);
|
|
58
|
+
const ipv4Cidr = new RegExp(`^${cidrv4}$`);
|
|
59
|
+
const ipv6Cidr = new RegExp(`^${cidrv6}$`);
|
|
60
|
+
const reverseDNS = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+(\.)$/;
|
|
61
|
+
const dashedIpv4 = /(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(-(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/;
|
|
62
|
+
const pathSegment = /^[_a-zA-Z0-9]([-_.a-zA-Z0-9]*[_a-zA-Z0-9])?$/;
|
|
63
|
+
const absolutePath = /^\/(([\w. -]*)[^\s?]\/?)+$/;
|
|
13
64
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
absoluteLinuxPath,
|
|
66
|
+
absolutePath,
|
|
67
|
+
accessKeyRegex,
|
|
68
|
+
advancedDomainName,
|
|
69
|
+
alpha,
|
|
70
|
+
alphaDashes,
|
|
71
|
+
alphaLowercase,
|
|
72
|
+
alphanum,
|
|
73
|
+
alphanumDash,
|
|
74
|
+
alphanumDashDots,
|
|
75
|
+
alphanumDashDotsOrEmpty,
|
|
76
|
+
alphanumDashDotsSpaces,
|
|
77
|
+
alphanumDashLowercase,
|
|
78
|
+
alphanumDashOrEmpty,
|
|
79
|
+
alphanumDashSpaces,
|
|
80
|
+
alphanumDashUnderscore,
|
|
81
|
+
alphanumDashUnderscoreDollar,
|
|
82
|
+
alphanumDashUnderscoreDots,
|
|
83
|
+
alphanumDashUnderscoreDotsSpaces,
|
|
84
|
+
alphanumDashUnderscoreDotsSpacesParenthesis,
|
|
85
|
+
alphanumDots,
|
|
86
|
+
alphanumLowercase,
|
|
87
|
+
ascii,
|
|
88
|
+
backupKey,
|
|
89
|
+
basicDomain,
|
|
90
|
+
cron,
|
|
91
|
+
dashedIpv4,
|
|
92
|
+
digits,
|
|
93
|
+
email,
|
|
94
|
+
fourDigitsCode,
|
|
95
|
+
hexadecimal,
|
|
96
|
+
ip,
|
|
97
|
+
ipCidr,
|
|
98
|
+
ipv4,
|
|
99
|
+
ipv4Cidr,
|
|
100
|
+
ipv6,
|
|
101
|
+
ipv6Cidr,
|
|
102
|
+
macAddress,
|
|
103
|
+
pathSegment,
|
|
104
|
+
phone,
|
|
105
|
+
reverseDNS,
|
|
106
|
+
s3BucketName,
|
|
107
|
+
sixDigitsCode,
|
|
108
|
+
spaces,
|
|
109
|
+
uppercaseBasicDomain,
|
|
110
|
+
uppercaseBasicSubdomain,
|
|
111
|
+
url
|
|
61
112
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/regex",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A small utility to use regex",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.x"
|
|
8
8
|
},
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
9
10
|
"sideEffects": false,
|
|
10
11
|
"module": "./dist/index.js",
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
@@ -30,6 +31,8 @@
|
|
|
30
31
|
"type:generate": "tsc --declaration -p tsconfig.build.json",
|
|
31
32
|
"build": "vite build --config vite.config.ts && pnpm run type:generate",
|
|
32
33
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|
|
33
|
-
"lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx ."
|
|
34
|
+
"lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",
|
|
35
|
+
"test:unit": "vitest --run --config vite.config.ts",
|
|
36
|
+
"test:unit:coverage": "pnpm test:unit --coverage"
|
|
34
37
|
}
|
|
35
38
|
}
|
package/vite.config.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
2
|
-
/* eslint-disable import/no-relative-packages */
|
|
3
|
-
/* eslint-disable-next-line import/no-extraneous-dependencies */
|
|
4
1
|
import { defineConfig, mergeConfig } from 'vite'
|
|
5
2
|
import { defaultConfig } from '../../vite.config'
|
|
6
3
|
|