Skip to content

Commit 347990f

Browse files
author
mjolly
committed
fix(regex): exclude @ as first letter for password regex
1 parent 8b076aa commit 347990f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.changeset/nice-worms-give.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+
fix(regex): exclude @ as first letter for password regex

packages/regex/src/__tests__/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ describe('@regex', () => {
11261126
['Password123!@#', true],
11271127
['password`', false],
11281128
['Password`123!@#', false],
1129+
['@Password123!@#', false],
11291130
])('should match regex %s to be %s', (string, expected) => {
11301131
expect(password.test(string)).toBe(expected)
11311132
})

packages/regex/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ export const absolutePath = /^\/(([\w. -]*)[^\s?]\/?)+$/
9393
export const sgPortRange =
9494
/^(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5]?[0-9]{1,4})(-(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5]?[0-9]{1,4}))?$/
9595

96-
// Include all characters except backtick `
97-
export const password = /^[^`]+$/
96+
// Include all characters except backtick ` and @ as first character
97+
export const password = /^(?!@)[^`]*$/

0 commit comments

Comments
 (0)