From 57a818453104c7484d556efa159813495b5b0b94 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Sat, 11 Apr 2020 12:07:30 +0300 Subject: [PATCH] fix(v2): treat mailto and tel links properly --- .../src/client/exports/__tests__/isInternalUrl.ts | 8 ++++++++ packages/docusaurus/src/client/exports/isInternalUrl.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/client/exports/__tests__/isInternalUrl.ts b/packages/docusaurus/src/client/exports/__tests__/isInternalUrl.ts index bc0833dd89e5..1d7bef97da21 100644 --- a/packages/docusaurus/src/client/exports/__tests__/isInternalUrl.ts +++ b/packages/docusaurus/src/client/exports/__tests__/isInternalUrl.ts @@ -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(); + }); }); diff --git a/packages/docusaurus/src/client/exports/isInternalUrl.js b/packages/docusaurus/src/client/exports/isInternalUrl.js index 182de277fe4b..9e7acfc81856 100644 --- a/packages/docusaurus/src/client/exports/isInternalUrl.js +++ b/packages/docusaurus/src/client/exports/isInternalUrl.js @@ -6,5 +6,5 @@ */ export default function isInternalUrl(url) { - return /^(https?:|\/\/)/.test(url) === false; + return /^(https?:|\/\/|mailto:|tel:)/.test(url) === false; }