Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/utils/__tests__/withdraw.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ describe('Withdraw Utilities', () => {
// Should keep existing + prefix
['+5511999999999', '+5511999999999'],
['+551199999999', '+551199999999'],
// Should strip separators even when the + prefix is already present
['+55-11-99999-9999', '+5511999999999'],
['+55 11 99999 9999', '+5511999999999'],
// Should not modify non-phone formats
['12345678901', '12345678901'], // CPF
['12345678901234', '12345678901234'], // CNPJ
Expand Down
9 changes: 5 additions & 4 deletions src/utils/withdraw.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ export const isPixPhoneNumber = (pixKey: string): boolean => {
*/
export const normalizePixPhoneNumber = (pixKey: string): string => {
const cleaned = pixKey.replace(/[\s-]/g, '')
if (isPixPhoneNumber(cleaned) && !cleaned.startsWith('+')) {
return '+' + cleaned
}
return pixKey
if (!isPixPhoneNumber(cleaned)) return pixKey
// Always return the separator-free +55 form. The old code returned the raw
// input untouched when it already started with '+', so inputs like
// '+55-11-99999-9999' kept their separators and stayed non-canonical.
return cleaned.startsWith('+') ? cleaned : '+' + cleaned
}

/**
Expand Down
Loading