Skip to content
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 #8159

Merged
merged 3 commits into from Oct 2, 2022

Conversation

forgeRW
Copy link
Contributor

@forgeRW forgeRW commented Oct 1, 2022

Pre-flight checklist

Motivation

The error is uncleared that an invalid URL is provided in the Docusaurus config file. The error is thrown by the normalizeURL function (/path/node_modules/sitemap/dist/lib/utils.js:274:15) so this PR adds code to catch the TypeError from the normalizeURL function and throw an error for an invalid URL.

Test Plan

Test links

I added a unit test to verify my code.

Related issues/PRs

Related to #8116

* Also add unit test to check error is thrown
@facebook-github-bot
Copy link
Contributor

Hi @forgeRW!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@netlify
Copy link

netlify bot commented Oct 1, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit c017e26
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6339ab8e194a2b0008e9260f
😎 Deploy Preview https://deploy-preview-8159--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Oct 1, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 85 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 87 🟢 100 🟢 100 🟢 100 🟢 90 Report

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 2, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

* Throw error for invalid URL in Docusaurus config file
* Perform error check in configValidation.ts
* Undo error check in createSitemap.ts
@Josh-Cena Josh-Cena added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Oct 2, 2022
@Josh-Cena Josh-Cena changed the title fix: throw error for invalid URL in Docusaurus config file fix(core): throw error for invalid URL in config file Oct 2, 2022
Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Josh-Cena Josh-Cena merged commit 53dbbe3 into facebook:main Oct 2, 2022
@slorber slorber added the to backport This PR is planned to be backported to a stable version of Docusaurus label Oct 5, 2022
try {
const {pathname} = new URL(value);
if (pathname !== '/') {
helpers.warn('docusaurus.configValidationWarning', {
Copy link
Collaborator

@slorber slorber Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

in case you want to follow-up, I think we should make this other case an error instead of a warning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I'll work on this and make a new PR.

slorber pushed a commit that referenced this pull request Oct 28, 2022
* fix: throw error for invalid URL in Docusaurus config file

* Also add unit test to check error is thrown

* fix: perform error check for invalid URL to configValidation.ts

* Throw error for invalid URL in Docusaurus config file
* Perform error check in configValidation.ts
* Undo error check in createSitemap.ts

* Better message

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Invalid URL while trying to build with sitemap not set to false
4 participants