fix(v2): reject routeBasePath: '' (#3377)

* routeBasePath: '' should be forbidden

* routeBasePath: '' should be forbidden

* commit

* try to trigger cla bot
This commit is contained in:
Sébastien Lorber 2020-08-31 19:59:27 +02:00 committed by GitHub
parent d8cfabb66a
commit 1eb6e13fb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 24 deletions

View file

@ -16,6 +16,7 @@
"@types/hapi__joi": "^17.1.2"
},
"dependencies": {
"@docusaurus/utils": "^2.0.0-alpha.62",
"@hapi/joi": "17.1.1",
"chalk": "^3.0.0"
},

View file

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import * as Joi from '@hapi/joi';
import {isValidPathname} from '@docusaurus/utils';
export const PluginIdSchema = Joi.string()
.regex(/^[a-zA-Z_\-]+$/)
@ -39,3 +40,15 @@ export const URISchema = Joi.alternatives(
}
}),
);
export const PathnameSchema = Joi.string()
.custom((val) => {
if (!isValidPathname(val)) {
throw new Error();
} else {
return val;
}
})
.message(
'{{#label}} is not a valid pathname. Pathname should start with / and not contain any domain or query string',
);