fix: enhancement of isExternal (#2093)

This commit is contained in:
沈唁 2023-06-18 11:51:32 +08:00 committed by GitHub
parent 46333edc69
commit 7f13ba0f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -96,5 +96,8 @@ export function isExternal(url) {
) {
return true;
}
if (/^\/\\/.test(url)) {
return true;
}
return false;
}

View File

@ -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();
});
});
});