Skip to content

Commit a1fc21c

Browse files
fix(ui): don't treat numeric usernames as phone numbers (#8532)
1 parent 5d3d31a commit a1fc21c

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

.changeset/quiet-dancers-carry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
fix(ui): don't treat numeric usernames as phone numbers

packages/ui/src/utils/__tests__/formatSafeIdentifier.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('formatSafeIdentifier', () => {
88
['h***@***.com', 'h***@***.com'],
99
['username', 'username'],
1010
['u***e', 'u***e'],
11+
['4245554242', '4245554242'],
1112
['+71111111111', '+7 111 111-11-11'],
1213
['+791*******1', '+791*******1'],
1314
];

packages/ui/src/utils/formatSafeIdentifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const isMaskedIdentifier = (str: string | undefined | null) => str && str
88
* Refer to the tests for examples.
99
*/
1010
export const formatSafeIdentifier = (str: string | undefined | null) => {
11-
if (!str || str.includes('@') || isMaskedIdentifier(str) || str.match(/[a-zA-Z]/)) {
11+
if (!str || str.includes('@') || isMaskedIdentifier(str) || str.match(/[a-zA-Z]/) || !str.startsWith('+')) {
1212
return str;
1313
}
1414
return stringToFormattedPhoneString(str);

0 commit comments

Comments
 (0)