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(gatsby): handle encoded URLs in SSR #39157

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fix(serve): improve URL handling and fix linting issues (#39010)
- Replace single quotes with backticks for consistency
- Add explicit express.RequestHandler return type
- Fix prettier formatting for template literals
- Improve code formatting and readability
emmron committed Nov 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ec3e5802098c5fb67bed9b3d88b9019a112aa4ec
2 changes: 1 addition & 1 deletion packages/gatsby/src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ const sanitizeUrl = (url: string): string => {
try {
// Decode URL and normalize slashes
const decoded = decodeURIComponent(url)
return decoded.replace(/\/+/g, '/').replace(/\/$/, '') || '/'
return decoded.replace(/\/+/g, `/`).replace(/\/$/, ``) || `/`
} catch (e) {
report.warn(`Failed to decode URL: ${url}`)
return url