@scaleway/regex 5.0.1 → 5.2.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 +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +112 -57
- package/package.json +6 -2
- package/vite.config.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2132](https://github.com/scaleway/scaleway-lib/pull/2132) [`fbe702b`](https://github.com/scaleway/scaleway-lib/commit/fbe702b32aa734e46836d267c23ddcc960b2d550) Thanks [@JulienSaguez](https://github.com/JulienSaguez)! - Add `elevenDigitsCode` and `nineDigitsCode` regex
|
|
8
|
+
|
|
9
|
+
## 5.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 5.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare const fourDigitsCode: RegExp;
|
|
|
32
32
|
export declare const phone: RegExp;
|
|
33
33
|
export declare const spaces: RegExp;
|
|
34
34
|
export declare const sixDigitsCode: RegExp;
|
|
35
|
+
export declare const nineDigitsCode: RegExp;
|
|
36
|
+
export declare const elevenDigitsCode: RegExp;
|
|
35
37
|
export declare const url: RegExp;
|
|
36
38
|
export declare const hexadecimal: RegExp;
|
|
37
39
|
export declare const s3BucketName: RegExp;
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,116 @@
|
|
|
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 nineDigitsCode = /^[0-9]{9}$/;
|
|
36
|
+
const elevenDigitsCode = /^[0-9]{11}$/;
|
|
37
|
+
const url = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
|
|
38
|
+
const hexadecimal = /^[0-9a-fA-F]+$/;
|
|
39
|
+
const s3BucketName = /^[a-z0-9][-.a-z0-9]{1,61}[a-z0-9]$/;
|
|
40
|
+
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}";
|
|
41
|
+
const v6segment = "[a-fA-F\\d]{1,4}";
|
|
42
|
+
const v6 = `
|
|
2
43
|
(?:
|
|
3
|
-
(?:${
|
|
4
|
-
(?:${
|
|
5
|
-
(?:${
|
|
6
|
-
(?:${
|
|
7
|
-
(?:${
|
|
8
|
-
(?:${
|
|
9
|
-
(?:${
|
|
10
|
-
(?::(?:(?::${
|
|
44
|
+
(?:${v6segment}:){7}(?:${v6segment}|:)|
|
|
45
|
+
(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)|
|
|
46
|
+
(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)|
|
|
47
|
+
(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)|
|
|
48
|
+
(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)|
|
|
49
|
+
(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)|
|
|
50
|
+
(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)|
|
|
51
|
+
(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:))
|
|
11
52
|
)(?:%[0-9a-zA-Z]{1,})?
|
|
12
|
-
`.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim()
|
|
53
|
+
`.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
|
|
54
|
+
const cidrv4 = `${v4}\\/(3[0-2]|[12]?[0-9])`;
|
|
55
|
+
const cidrv6 = `${v6}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;
|
|
56
|
+
const ip = new RegExp(`^(?:${v4}|${v6})$`);
|
|
57
|
+
const ipv4 = new RegExp(`^${v4}$`);
|
|
58
|
+
const ipv6 = new RegExp(`^${v6}$`);
|
|
59
|
+
const ipCidr = new RegExp(`(?:^${cidrv4}$)|(?:^${cidrv6}$)`);
|
|
60
|
+
const ipv4Cidr = new RegExp(`^${cidrv4}$`);
|
|
61
|
+
const ipv6Cidr = new RegExp(`^${cidrv6}$`);
|
|
62
|
+
const reverseDNS = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+(\.)$/;
|
|
63
|
+
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}/;
|
|
64
|
+
const pathSegment = /^[_a-zA-Z0-9]([-_.a-zA-Z0-9]*[_a-zA-Z0-9])?$/;
|
|
65
|
+
const absolutePath = /^\/(([\w. -]*)[^\s?]\/?)+$/;
|
|
13
66
|
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
|
-
|
|
67
|
+
absoluteLinuxPath,
|
|
68
|
+
absolutePath,
|
|
69
|
+
accessKeyRegex,
|
|
70
|
+
advancedDomainName,
|
|
71
|
+
alpha,
|
|
72
|
+
alphaDashes,
|
|
73
|
+
alphaLowercase,
|
|
74
|
+
alphanum,
|
|
75
|
+
alphanumDash,
|
|
76
|
+
alphanumDashDots,
|
|
77
|
+
alphanumDashDotsOrEmpty,
|
|
78
|
+
alphanumDashDotsSpaces,
|
|
79
|
+
alphanumDashLowercase,
|
|
80
|
+
alphanumDashOrEmpty,
|
|
81
|
+
alphanumDashSpaces,
|
|
82
|
+
alphanumDashUnderscore,
|
|
83
|
+
alphanumDashUnderscoreDollar,
|
|
84
|
+
alphanumDashUnderscoreDots,
|
|
85
|
+
alphanumDashUnderscoreDotsSpaces,
|
|
86
|
+
alphanumDashUnderscoreDotsSpacesParenthesis,
|
|
87
|
+
alphanumDots,
|
|
88
|
+
alphanumLowercase,
|
|
89
|
+
ascii,
|
|
90
|
+
backupKey,
|
|
91
|
+
basicDomain,
|
|
92
|
+
cron,
|
|
93
|
+
dashedIpv4,
|
|
94
|
+
digits,
|
|
95
|
+
elevenDigitsCode,
|
|
96
|
+
email,
|
|
97
|
+
fourDigitsCode,
|
|
98
|
+
hexadecimal,
|
|
99
|
+
ip,
|
|
100
|
+
ipCidr,
|
|
101
|
+
ipv4,
|
|
102
|
+
ipv4Cidr,
|
|
103
|
+
ipv6,
|
|
104
|
+
ipv6Cidr,
|
|
105
|
+
macAddress,
|
|
106
|
+
nineDigitsCode,
|
|
107
|
+
pathSegment,
|
|
108
|
+
phone,
|
|
109
|
+
reverseDNS,
|
|
110
|
+
s3BucketName,
|
|
111
|
+
sixDigitsCode,
|
|
112
|
+
spaces,
|
|
113
|
+
uppercaseBasicDomain,
|
|
114
|
+
uppercaseBasicSubdomain,
|
|
115
|
+
url
|
|
61
116
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/regex",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.2.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",
|
|
@@ -26,10 +27,13 @@
|
|
|
26
27
|
},
|
|
27
28
|
"license": "MIT",
|
|
28
29
|
"scripts": {
|
|
30
|
+
"prebuild": "shx rm -rf dist",
|
|
29
31
|
"typecheck": "tsc --noEmit",
|
|
30
32
|
"type:generate": "tsc --declaration -p tsconfig.build.json",
|
|
31
33
|
"build": "vite build --config vite.config.ts && pnpm run type:generate",
|
|
32
34
|
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|
|
33
|
-
"lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx ."
|
|
35
|
+
"lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",
|
|
36
|
+
"test:unit": "vitest --run --config vite.config.ts",
|
|
37
|
+
"test:unit:coverage": "pnpm test:unit --coverage"
|
|
34
38
|
}
|
|
35
39
|
}
|
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
|
|