New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): throw error for invalid URL in config file #8192
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,9 +158,7 @@ const SiteUrlSchema = Joi.string() | |
try { | ||
const {pathname} = new URL(value); | ||
if (pathname !== '/') { | ||
helpers.warn('docusaurus.configValidationWarning', { | ||
warningMessage: `The url is not supposed to contain a sub-path like '${pathname}'. Please use the baseUrl field for sub-paths.`, | ||
}); | ||
return helpers.error('docusaurus.configValidationWarning'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should use Unfortunately I can't really guide you to the correct solution: Joi is really a pain to do anything basic such as returning a custom error message 😅 |
||
} | ||
} catch { | ||
return helpers.error('any.invalid'); | ||
|
@@ -170,6 +168,8 @@ const SiteUrlSchema = Joi.string() | |
.messages({ | ||
'any.invalid': | ||
'"{#value}" does not look like a valid URL. Make sure it has a protocol; for example, "https://example.com".', | ||
'docusaurus.configValidationWarning': | ||
'The url is not supposed to contain a sub-path like "{#pathname}". Please use the baseUrl field for sub-paths.', | ||
}); | ||
|
||
// TODO move to @docusaurus/utils-validation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need this anymore, at least not in this test group, because here it's not testing URL normalization but URL rejection so this feels weird