fix(v2): relax URI validation (#3227)

* relax URI validation

* add regex

* add test

* fix linting error

* fix formatting

* use URL rather than regex
This commit is contained in:
Anshul Goyal 2020-08-08 01:41:19 +05:30 committed by GitHub
parent fe281a8ebe
commit 181a6174c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 44 additions and 7 deletions

View file

@ -12,6 +12,7 @@ import {
RehypePluginsSchema,
RemarkPluginsSchema,
PluginIdSchema,
URISchema,
} from '../validationSchemas';
function createTestHelpers({
@ -106,4 +107,16 @@ describe('validation schemas', () => {
test('RehypePluginsSchema', () => {
testMarkdownPluginSchemas(RehypePluginsSchema);
});
test('URISchema', () => {
const validURL = 'https://docusaurus.io';
const doubleHash = 'https://docusaurus.io#github#/:';
const invalidURL = 'invalidURL';
const urlFromIssue = 'https://riot.im/app/#/room/#ligo-public:matrix.org';
const {testFail, testOK} = createTestHelpers({schema: URISchema});
testOK(validURL);
testOK(doubleHash);
testFail(invalidURL);
testOK(urlFromIssue);
});
});