mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 02:56:57 +02:00
add isValidPathname
This commit is contained in:
parent
4e8b361d00
commit
da8ccd0419
2 changed files with 29 additions and 0 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
objectWithKeySorted,
|
||||
aliasedSitePath,
|
||||
createExcerpt,
|
||||
isValidPathname,
|
||||
} from '../index';
|
||||
|
||||
describe('load utils', () => {
|
||||
|
@ -363,4 +364,20 @@ describe('load utils', () => {
|
|||
expect(createExcerpt(testCase.input)).toEqual(testCase.output);
|
||||
});
|
||||
});
|
||||
|
||||
test('isValidPathname', () => {
|
||||
expect(isValidPathname('/')).toBe(true);
|
||||
expect(isValidPathname('/hey')).toBe(true);
|
||||
expect(isValidPathname('/hey/ho')).toBe(true);
|
||||
expect(isValidPathname('/hey/ho/')).toBe(true);
|
||||
expect(isValidPathname('/hey/h%C3%B4/')).toBe(true);
|
||||
expect(isValidPathname('/hey///ho///')).toBe(true); // Unexpected but valid
|
||||
//
|
||||
expect(isValidPathname('')).toBe(false);
|
||||
expect(isValidPathname('hey')).toBe(false);
|
||||
expect(isValidPathname('/hey/hô')).toBe(false);
|
||||
expect(isValidPathname('/hey?qs=ho')).toBe(false);
|
||||
expect(isValidPathname('https://fb.com/hey')).toBe(false);
|
||||
expect(isValidPathname('//hey')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue