Skip to content

Commit

Permalink
fix: enhancement of isExternal (#2093)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jun 24, 2023
1 parent 68d8735 commit 6a7d15b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/util/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@ export function isExternal(url) {
) {
return true;
}
if (/^\/\\/.test(url)) {
return true;
}
return false;
}
12 changes: 12 additions & 0 deletions test/unit/core-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

0 comments on commit 6a7d15b

Please sign in to comment.