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): fix docusaurus serve broken for assets when using trailingSlash #10142

Merged
merged 1 commit into from
May 16, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented May 16, 2024

Motivation

Fix #10139

The workaround applied in #10090 lead to a regression for serving assets. I'm now applying this workaround more defensively.

The workaround impl is not 100% robust but should work fine for 99.9% of websites and only applies to sites using docusauris serve with a baseurl + trailingSlash.

Test Plan

no 😅 it works locally

@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label May 16, 2024
@slorber slorber requested a review from Josh-Cena as a code owner May 16, 2024 11:07
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 16, 2024
Copy link

netlify bot commented May 16, 2024

[V2]

Name Link
🔨 Latest commit 33603df
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6645e8fbb386980007b4ae61
😎 Deploy Preview https://deploy-preview-10142--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 configuration.

Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 72 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 70 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 70 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 63 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 71 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

Size Change: 0 B

Total Size: 1.71 MB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/codeTranslations.json 2 B
website/.docusaurus/docusaurus.config.mjs 26.9 kB
website/.docusaurus/globalData.json 107 kB
website/.docusaurus/i18n.json 930 B
website/.docusaurus/registry.js 275 kB
website/.docusaurus/routes.js 179 kB
website/.docusaurus/routesChunkNames.json 119 kB
website/.docusaurus/site-metadata.json 2.17 kB
website/build/assets/css/styles.********.css 112 kB
website/build/assets/js/main.********.js 853 kB
website/build/index.html 38.1 kB

compressed-size-action

@slorber slorber changed the title fix(core): docusaurus serve is broken for assets fix(core): fix docusaurus serve broken for assets when using trailingSlash May 16, 2024
@slorber slorber merged commit 87f0023 into main May 16, 2024
31 checks passed
@slorber slorber deleted the slorber/fix-serve-assets-trailingSlash-bug branch May 16, 2024 12:29
if (baseUrl !== '/') {
// Not super robust, but should be good enough for our use case
// See https://github.com/facebook/docusaurus/pull/10090
const looksLikeAsset = !!req.url.match(/.[a-z]{1,4}$/);

Choose a reason for hiding this comment

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

Maybe *.mp3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, not sure why I assumed extensions could only contain lowercase letters 😅

#10145

tas50 added a commit to mondoohq/docs that referenced this pull request May 31, 2024
This fixed our trailing slash bug via facebook/docusaurus#10142

Signed-off-by: Tim Smith <tsmith84@gmail.com>
misterpantz pushed a commit to mondoohq/docs that referenced this pull request May 31, 2024
This fixed our trailing slash bug via facebook/docusaurus#10142

Signed-off-by: Tim Smith <tsmith84@gmail.com>
@d4nyll d4nyll mentioned this pull request Jun 17, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trailing Slash Appended to Asset Files in Docusaurus 3.3.2
3 participants