From bba3ca5ce9c7809ca4c231ac794306045f1042d2 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Fri, 16 Jun 2023 15:02:45 +0800 Subject: [PATCH 1/2] fix: Enhancement of isExternal --- src/core/util/core.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/util/core.js b/src/core/util/core.js index 985a0e829..e1e585d53 100644 --- a/src/core/util/core.js +++ b/src/core/util/core.js @@ -96,5 +96,8 @@ export function isExternal(url) { ) { return true; } + if (/^\/\\/.test(url)) { + return true; + } return false; } From 942a162d2f91019c01065d5ffb03cfb94b7e020c Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Fri, 16 Jun 2023 15:20:48 +0800 Subject: [PATCH 2/2] test: add test for isExternal --- test/unit/core-util.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/unit/core-util.test.js b/test/unit/core-util.test.js index 0ebbf7bbd..a6ff7d3ef 100644 --- a/test/unit/core-util.test.js +++ b/test/unit/core-util.test.js @@ -59,5 +59,17 @@ describe('core/util', () => { expect(result).toBeTruthy(); }); + + test('external url with one \\', () => { + const result = isExternal('/\\example.github.io/docsify/demo.md'); + + expect(result).toBeTruthy(); + }); + + test('external url with two \\', () => { + const result = isExternal('/\\\\example.github.io/docsify/demo.md'); + + expect(result).toBeTruthy(); + }); }); });