fix(v2): treat mailto and tel links properly (#2579)

This commit is contained in:
Alexey Pyltsyn 2020-04-11 17:59:32 +03:00 committed by GitHub
parent d531735b3a
commit 399fcbd7eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -27,4 +27,12 @@ describe('isInternalUrl', () => {
test('should be false for whatever protocol links', () => {
expect(isInternalUrl('//foo.com')).toBeFalsy();
});
test('should be false for telephone links', () => {
expect(isInternalUrl('tel:+1234567890')).toBeFalsy();
});
test('should be false for mailto links', () => {
expect(isInternalUrl('mailto:someone@example.com')).toBeFalsy();
});
});

View file

@ -6,5 +6,5 @@
*/
export default function isInternalUrl(url) {
return /^(https?:|\/\/)/.test(url) === false;
return /^(https?:|\/\/|mailto:|tel:)/.test(url) === false;
}