Skip to content

Commit

Permalink
fix(v2): treat mailto and tel links properly
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Apr 11, 2020
1 parent a8ab0d6 commit 57a8184
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion packages/docusaurus/src/client/exports/isInternalUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
*/

export default function isInternalUrl(url) {
return /^(https?:|\/\/)/.test(url) === false;
return /^(https?:|\/\/|mailto:|tel:)/.test(url) === false;
}

0 comments on commit 57a8184

Please sign in to comment.