mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-18 00:57:51 +02:00
fix(docusaurus-utils-validation): baseUrl + routeBasePath: allow empty string, normalized as "/" (#8258)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com> fix https://github.com/facebook/docusaurus/issues/8254
This commit is contained in:
parent
85d0b5674f
commit
e553ce7e59
12 changed files with 92 additions and 17 deletions
|
@ -33,7 +33,7 @@ describe('normalizePagesPluginOptions', () => {
|
|||
it('accepts correctly defined user options', () => {
|
||||
const userOptions = {
|
||||
path: 'src/my-pages',
|
||||
routeBasePath: 'my-pages',
|
||||
routeBasePath: '/my-pages',
|
||||
include: ['**/*.{js,jsx,ts,tsx}'],
|
||||
exclude: ['**/$*/'],
|
||||
};
|
||||
|
@ -51,4 +51,15 @@ describe('normalizePagesPluginOptions', () => {
|
|||
});
|
||||
}).toThrowErrorMatchingInlineSnapshot(`""path" must be a string"`);
|
||||
});
|
||||
|
||||
it('empty routeBasePath replace default path("/")', () => {
|
||||
expect(
|
||||
testValidate({
|
||||
routeBasePath: '',
|
||||
}),
|
||||
).toEqual({
|
||||
...defaultOptions,
|
||||
routeBasePath: '/',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
RemarkPluginsSchema,
|
||||
RehypePluginsSchema,
|
||||
AdmonitionsSchema,
|
||||
RouteBasePathSchema,
|
||||
} from '@docusaurus/utils-validation';
|
||||
import {GlobExcludeDefault} from '@docusaurus/utils';
|
||||
import type {OptionValidationContext} from '@docusaurus/types';
|
||||
|
@ -30,7 +31,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
|
||||
const PluginOptionSchema = Joi.object<PluginOptions>({
|
||||
path: Joi.string().default(DEFAULT_OPTIONS.path),
|
||||
routeBasePath: Joi.string().default(DEFAULT_OPTIONS.routeBasePath),
|
||||
routeBasePath: RouteBasePathSchema.default(DEFAULT_OPTIONS.routeBasePath),
|
||||
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
||||
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
||||
mdxPageComponent: Joi.string().default(DEFAULT_OPTIONS.mdxPageComponent),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue