fix(v2): less strict blog/docs uri frontmatter validation (#5032)

This commit is contained in:
Sébastien Lorber 2021-06-22 10:42:06 +02:00 committed by GitHub
parent 425eccc5df
commit f20599bb54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 151 additions and 52 deletions

View file

@ -25,8 +25,11 @@ export const RehypePluginsSchema = MarkdownPluginsSchema;
export const AdmonitionsSchema = Joi.object().default({});
// TODO how can we make this emit a custom error message :'(
// Joi is such a pain, good luck to annoying trying to improve this
export const URISchema = Joi.alternatives(
Joi.string().uri({allowRelative: true}),
// 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);