Skip to content

Commit 1af34cb

Browse files
authored
fix(regex): add test and fix changeset for new Scaleway access key regex (#1254)
1 parent 4aee099 commit 1af34cb

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

.changeset/chilly-spies-melt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@scaleway/regex': patch
3+
---
4+
5+
Add Scaleway access key regex.

.changeset/regex-20230322.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/regex/src/__tests__/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
absoluteLinuxPath,
3+
accessKeyRegex,
34
advancedDomainName,
45
alpha,
56
alphaDashes,
@@ -912,4 +913,17 @@ describe('@regex', () => {
912913
expect(dashedIpv4.test(string)).toBe(expected)
913914
})
914915
})
916+
917+
describe('accessKeyRegex', () => {
918+
test.each([
919+
['12301234567891234567', false],
920+
['ABCABCDEFGHIJKLMNOPQ', false],
921+
['SCWabcdefghijklmnopq', true],
922+
['scw01234567891234567', true],
923+
['SCW01234567891234567', true],
924+
['SCWABCDEFGHIJKLMNOPQ', true],
925+
])('should match regex %s to be %s', (string, expected) => {
926+
expect(accessKeyRegex.test(string)).toBe(expected)
927+
})
928+
})
915929
})

packages/regex/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const accessKeyRegex = /^SCW[A-Z0-9]{17}$/i
12
export const alpha = /^[a-zA-Z]*$/
23
export const alphaLower = /^[a-z]+$/
34
export const alphanum = /^[a-zA-Z0-9]*$/
@@ -78,5 +79,3 @@ export const ipv6Cidr = new RegExp(`^${cidrv6}$`)
7879
export const reverseDNS = /^[a-z0-9-]+(\.[a-z0-9-]{1,63})+(\.)$/
7980
export const dashedIpv4 =
8081
/(\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}/
81-
82-
export const accessKeyRegex = /^SCW[A-Z0-9]{17}$/i

0 commit comments

Comments
 (0)