-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: handle trailing slash on the image endpoint #12022
Conversation
🦋 Changeset detectedLatest commit: 8579d22 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Instead of adding import.meta.env.*
. Maybe we can add the trailing slash to endpoint.route
directly here?
astro/packages/astro/src/core/config/schema.ts
Lines 648 to 670 in b082702
.transform((config) => { | |
// If the user changed `outDir`, we need to also update `build.client` and `build.server` | |
// the be based on the correct `outDir` | |
if ( | |
config.outDir.toString() !== | |
resolveDirAsUrl(ASTRO_CONFIG_DEFAULTS.outDir, fileProtocolRoot).toString() | |
) { | |
const outDirPath = fileURLToPath(config.outDir); | |
config.build.client = resolveDirAsUrl(originalBuildClient, outDirPath); | |
config.build.server = resolveDirAsUrl(originalBuildServer, outDirPath); | |
} | |
// Handle `base` trailing slash based on `trailingSlash` config | |
if (config.trailingSlash === 'never') { | |
config.base = prependForwardSlash(removeTrailingForwardSlash(config.base)); | |
} else if (config.trailingSlash === 'always') { | |
config.base = prependForwardSlash(appendForwardSlash(config.base)); | |
} else { | |
config.base = prependForwardSlash(config.base); | |
} | |
return config; | |
}) |
I thought about it, but I figured that this value is generally useful to users when building URLs (much like BASE_URL or ASSET_PREFIX is) so we might as well expose it, what do you think? |
I think there's value in it too, but for now it might collide with my plan to make the So I personally would hold off for a bit, but even if this goes through is not a very big deal 😅 |
Okay, I'll adjust and we can kick the can of "how to access config values in Astro" even further down the road 🫡 |
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.
Why does the PR point next
and not main
?
you can't customize the endpoint route in main, so this is not relevant. You'd have to fix the issue completely differently, but the issue on main is more niche than it is now on next |
Changes
Add a trailing slash to the image endpoint based on the trailing slash config, like we do for base
Fixes #11568
Testing
Added tests
Docs
N/A