@scaleway/regex 2.2.2 → 2.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/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 2.4.0 (2022-09-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * **regex:** add ip regexes ([#972](https://github.com/scaleway/scaleway-lib/issues/972)) ([98c6ded](https://github.com/scaleway/scaleway-lib/commit/98c6deda557af0cd41b1a6064946af2dea6680c2))
12
+
13
+
14
+
15
+ ## 2.3.0 (2022-08-01)
16
+
17
+
18
+ ### Features
19
+
20
+ * add new regex `alphaDashes` to the list ([#901](https://github.com/scaleway/scaleway-lib/issues/901)) ([608f823](https://github.com/scaleway/scaleway-lib/commit/608f8230badb68dcbcb5eab95c1661f97652a042))
21
+
22
+
23
+
24
+ ### 2.2.3 (2022-04-26)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * **regex:** improve url regex ([#736](https://github.com/scaleway/scaleway-lib/issues/736)) ([c340227](https://github.com/scaleway/scaleway-lib/commit/c340227da34141c978237e7659404df84e680d7a))
30
+
31
+
32
+
6
33
  ### 2.2.2 (2022-04-05)
7
34
 
8
35
  **Note:** Version bump only for package @scaleway/regex
@@ -1,6 +1,7 @@
1
1
  const alpha = /^[a-zA-Z]*$/;
2
2
  const alphaLower = /^[a-z]+$/;
3
3
  const alphanum = /^[a-zA-Z0-9]*$/;
4
+ const alphaDashes = /^[a-zA-Z-]*$/;
4
5
  const alphanumdash = /^[a-zA-Z0-9-]*$/;
5
6
  const alphanumdashdots = /^[a-zA-Z0-9-.]*$/;
6
7
  const alphanumdashdotsorempty = /^$|^[a-zA-Z0-9-.]*$/;
@@ -12,21 +13,36 @@ const alphanumLowercase = /^[a-z0-9]+$/;
12
13
  const alphanumSpacesDotsUnderscoreDash = /^[a-zA-Z0-9-.\s_]*$/;
13
14
  const alphanumUnderscoreDash = /^[a-zA-Z0-9_-]*$/;
14
15
  const alphanumUnderscoreDollarDash = /^[a-zA-Z0-9_$-]*$/;
15
- const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/; // eslint-disable-next-line no-control-regex
16
-
16
+ const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/;
17
17
  const ascii = /^[\x00-\x7F]+$/;
18
18
  const backupKey = /^[A-Z0-9]{32}$/;
19
19
  const basicDomain = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+$/;
20
20
  const cron = /^[0-9,/*-]+$/;
21
21
  const digits = /^[0-9]*$/;
22
- const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; // Used by W3C
23
-
22
+ const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
24
23
  const email = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
25
24
  const fourDigitsCode = /^[0-9]{4}$/;
26
25
  const phone = /^\+[0-9]*/;
27
26
  const spaces = /^\s*$/;
28
27
  const sixDigitsCode = /^[0-9]{6}$/;
29
- const url = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
28
+ const url = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
30
29
  const hexadecimal = /^[0-9a-fA-F]+$/;
30
+ 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}';
31
+ const v6segment = '[a-fA-F\\d]{1,4}';
32
+ const v6 = `
33
+ (?:
34
+ (?:${v6segment}:){7}(?:${v6segment}|:)|
35
+ (?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)|
36
+ (?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)|
37
+ (?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)|
38
+ (?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)|
39
+ (?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)|
40
+ (?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)|
41
+ (?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:))
42
+ )(?:%[0-9a-zA-Z]{1,})?
43
+ `.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
44
+ const ip = new RegExp(`^(?:${v4}|${v6})$`);
45
+ const ipv4 = new RegExp(`^${v4}$`);
46
+ const ipv6 = new RegExp(`^${v6}$`);
31
47
 
32
- export { absoluteLinuxPath, alpha, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, macAddress, phone, sixDigitsCode, spaces, url };
48
+ export { absoluteLinuxPath, alpha, alphaDashes, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, ip, ipv4, ipv6, macAddress, phone, sixDigitsCode, spaces, url };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare const alpha: RegExp;
2
2
  declare const alphaLower: RegExp;
3
3
  declare const alphanum: RegExp;
4
+ declare const alphaDashes: RegExp;
4
5
  declare const alphanumdash: RegExp;
5
6
  declare const alphanumdashdots: RegExp;
6
7
  declare const alphanumdashdotsorempty: RegExp;
@@ -26,5 +27,8 @@ declare const spaces: RegExp;
26
27
  declare const sixDigitsCode: RegExp;
27
28
  declare const url: RegExp;
28
29
  declare const hexadecimal: RegExp;
30
+ declare const ip: RegExp;
31
+ declare const ipv4: RegExp;
32
+ declare const ipv6: RegExp;
29
33
 
30
- export { absoluteLinuxPath, alpha, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, macAddress, phone, sixDigitsCode, spaces, url };
34
+ export { absoluteLinuxPath, alpha, alphaDashes, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, ip, ipv4, ipv6, macAddress, phone, sixDigitsCode, spaces, url };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const alpha = /^[a-zA-Z]*$/;
2
2
  const alphaLower = /^[a-z]+$/;
3
3
  const alphanum = /^[a-zA-Z0-9]*$/;
4
+ const alphaDashes = /^[a-zA-Z-]*$/;
4
5
  const alphanumdash = /^[a-zA-Z0-9-]*$/;
5
6
  const alphanumdashdots = /^[a-zA-Z0-9-.]*$/;
6
7
  const alphanumdashdotsorempty = /^$|^[a-zA-Z0-9-.]*$/;
@@ -12,21 +13,36 @@ const alphanumLowercase = /^[a-z0-9]+$/;
12
13
  const alphanumSpacesDotsUnderscoreDash = /^[a-zA-Z0-9-.\s_]*$/;
13
14
  const alphanumUnderscoreDash = /^[a-zA-Z0-9_-]*$/;
14
15
  const alphanumUnderscoreDollarDash = /^[a-zA-Z0-9_$-]*$/;
15
- const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/; // eslint-disable-next-line no-control-regex
16
-
16
+ const absoluteLinuxPath = /(^\/$|^(\/[a-zA-Z0-9_]+)*$)/;
17
17
  const ascii = /^[\x00-\x7F]+$/;
18
18
  const backupKey = /^[A-Z0-9]{32}$/;
19
19
  const basicDomain = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+$/;
20
20
  const cron = /^[0-9,/*-]+$/;
21
21
  const digits = /^[0-9]*$/;
22
- const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; // Used by W3C
23
-
22
+ const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
24
23
  const email = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
25
24
  const fourDigitsCode = /^[0-9]{4}$/;
26
25
  const phone = /^\+[0-9]*/;
27
26
  const spaces = /^\s*$/;
28
27
  const sixDigitsCode = /^[0-9]{6}$/;
29
- const url = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
28
+ const url = /^http(s)?:\/\/?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]+$/;
30
29
  const hexadecimal = /^[0-9a-fA-F]+$/;
30
+ 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}';
31
+ const v6segment = '[a-fA-F\\d]{1,4}';
32
+ const v6 = `
33
+ (?:
34
+ (?:${v6segment}:){7}(?:${v6segment}|:)|
35
+ (?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)|
36
+ (?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)|
37
+ (?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)|
38
+ (?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)|
39
+ (?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)|
40
+ (?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)|
41
+ (?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:))
42
+ )(?:%[0-9a-zA-Z]{1,})?
43
+ `.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
44
+ const ip = new RegExp(`^(?:${v4}|${v6})$`);
45
+ const ipv4 = new RegExp(`^${v4}$`);
46
+ const ipv6 = new RegExp(`^${v6}$`);
31
47
 
32
- export { absoluteLinuxPath, alpha, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, macAddress, phone, sixDigitsCode, spaces, url };
48
+ export { absoluteLinuxPath, alpha, alphaDashes, alphaLower, alphanum, alphanumLowercase, alphanumSpacesDotsUnderscoreDash, alphanumUnderscoreDash, alphanumUnderscoreDollarDash, alphanumdash, alphanumdashdots, alphanumdashdotsorempty, alphanumdashdotsspaces, alphanumdashorempty, alphanumdashspaces, alphanumdots, ascii, backupKey, basicDomain, cron, digits, email, fourDigitsCode, hexadecimal, ip, ipv4, ipv6, macAddress, phone, sixDigitsCode, spaces, url };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/regex",
3
- "version": "2.2.2",
3
+ "version": "2.4.0",
4
4
  "description": "A small utility to use regex",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,5 +18,5 @@
18
18
  "directory": "packages/regex"
19
19
  },
20
20
  "license": "MIT",
21
- "gitHead": "f5789858da50231e50baa15f68e757696c838a65"
21
+ "gitHead": "39fe32a6a46b5296c34b7c9a2f52eb753648e4e9"
22
22
  }