test(utils, mdx-loader, core): improve coverage ()

* test(utils, mdx-loader, core): improve coverage

* windows...

* fix
This commit is contained in:
Joshua Chen 2022-01-10 15:00:51 +08:00 committed by GitHub
parent cf265c051e
commit a79c23bc45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 841 additions and 219 deletions
packages/docusaurus-utils-validation/src

View file

@ -34,12 +34,9 @@ export const URISchema = Joi.alternatives(
// This custom validation logic is required notably because Joi does not accept paths like /a/b/c ...
Joi.custom((val, helpers) => {
try {
const url = new URL(val);
if (url) {
return val;
} else {
return helpers.error('any.invalid');
}
// eslint-disable-next-line no-new
new URL(val);
return val;
} catch {
return helpers.error('any.invalid');
}
@ -53,9 +50,8 @@ export const PathnameSchema = Joi.string()
.custom((val) => {
if (!isValidPathname(val)) {
throw new Error();
} else {
return val;
}
return val;
})
.message(
'{{#label}} is not a valid pathname. Pathname should start with slash and not contain any domain or query string.',