Skip to content

Commit

Permalink
fixing link can handle more than one mail
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Raghuwanshi committed Jan 16, 2025
1 parent 1c88feb commit 4d2360b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/volto/src/helpers/Url/Url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
normaliseMail,
normalizeTelephone,
flattenScales,
isMail,
} from './Url';

beforeEach(() => {
Expand Down Expand Up @@ -533,4 +534,18 @@ describe('Url', () => {
});
});
});

describe('isMail', () => {
it('isMale test', () => {
const mailExamples = [
'mailto:[email protected]',
'mailto:[email protected],[email protected]',
'mailto:[email protected][email protected]',
'mailto:[email protected]?subject=Hello&body=World',
];
for (let mail of mailExamples) {
expect(isMail(mail)).toBe(true);
}
});
});
});
2 changes: 1 addition & 1 deletion packages/volto/src/helpers/Url/urlRegex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tlds from 'tlds';

export const mailRegex = () =>
/^((mailto:[^<>()/[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
/^mailto:([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(,[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})*(\?[^<>()[\]\s]*)?$/i;

export const telRegex = () =>
/^[tel:]*[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s./0-9]*$/g;
Expand Down

0 comments on commit 4d2360b

Please sign in to comment.