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(astro/core): Do not automatically add trailing slash #5608

Merged
merged 4 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/twelve-cooks-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'astro': minor
bluwy marked this conversation as resolved.
Show resolved Hide resolved
---

Fixed a problem in which trailing slashes were automatically inserted for URLs set as 'site' key in astro.config.
Implementers should be aware that, for example, setting `${import.meta.env.SITE}ogp.png` to load an OGP will be converted to `https://example.comogp.png` and the image will not be loaded. As a result, the image may not load.

## What should consumer do?
Consumer should search `import.meta.env.SITE` when raising to this version and change it if they are writing code that expects the trailing slash to be added automatically.
konojunya marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 1 addition & 5 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export const AstroConfigSchema = z.object({
.optional()
.default(ASTRO_CONFIG_DEFAULTS.outDir)
.transform((val) => new URL(val)),
site: z
.string()
.url()
.optional()
.transform((val) => (val ? appendForwardSlash(val) : val)),
site: z.string().url().optional(),
base: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.base),
trailingSlash: z
.union([z.literal('always'), z.literal('never'), z.literal('ignore')])
Expand Down