mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
* Update linting configuration (eslint, prettier) * Fix lint issues following eslint prettier update * Change ESLint config to allow boolean coercion * Switch to default import name per docs * Fix suppression of error details * Update JSDoc comments * Update waiForFunctin to provide error details --------- Co-authored-by: Koy Zhuang <koy@ko8e24.top>
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
import { isExternal } from '../../src/core/util/index.js';
|
|
|
|
// Core util
|
|
// -----------------------------------------------------------------------------
|
|
describe('core/util', () => {
|
|
// isExternal()
|
|
// ---------------------------------------------------------------------------
|
|
describe('isExternal()', () => {
|
|
// cases non external
|
|
test('non external local url with one /', () => {
|
|
const result = isExternal(`/${location.host}/docsify/demo.md`);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
test('non external local url with two //', () => {
|
|
const result = isExternal(`//${location.host}/docsify/demo.md`);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
test('non external local url with three ///', () => {
|
|
const result = isExternal(`///${location.host}/docsify/demo.md`);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
test('non external local url with more /', () => {
|
|
const result = isExternal(
|
|
`//////////////////${location.host}/docsify/demo.md`,
|
|
);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
test('non external url with one /', () => {
|
|
const result = isExternal('/example.github.io/docsify/demo.md');
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
// cases is external
|
|
test('external url with two //', () => {
|
|
const result = isExternal('/docsify/demo.md');
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
test('external url with three ///', () => {
|
|
const result = isExternal('///example.github.io/docsify/demo.md');
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
test('external url with more /', () => {
|
|
const result = isExternal(
|
|
'//////////////////example.github.io/docsify/demo.md',
|
|
);
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|