From 4bdf3f3b1bdfe92e561d6bdd7dd047841f907b3d Mon Sep 17 00:00:00 2001 From: Junya Kono Date: Thu, 15 Dec 2022 07:00:33 +0900 Subject: [PATCH 1/3] fix: Do not automatically add trailing slash --- .changeset/twelve-cooks-tickle.md | 9 +++++++++ packages/astro/src/core/config/schema.ts | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/twelve-cooks-tickle.md diff --git a/.changeset/twelve-cooks-tickle.md b/.changeset/twelve-cooks-tickle.md new file mode 100644 index 000000000000..64e751acfbf8 --- /dev/null +++ b/.changeset/twelve-cooks-tickle.md @@ -0,0 +1,9 @@ +--- +'astro': minor +--- + +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. diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 33ef28aa4839..259d12a3329a 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -71,11 +71,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')]) From b988951c710d8b6418f4bef1678d1dc772ed5f57 Mon Sep 17 00:00:00 2001 From: Junya Kono Date: Thu, 12 Jan 2023 19:21:15 +0900 Subject: [PATCH 2/3] Update .changeset/twelve-cooks-tickle.md Co-authored-by: Bjorn Lu --- .changeset/twelve-cooks-tickle.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.changeset/twelve-cooks-tickle.md b/.changeset/twelve-cooks-tickle.md index 64e751acfbf8..c0f3cdbb29e9 100644 --- a/.changeset/twelve-cooks-tickle.md +++ b/.changeset/twelve-cooks-tickle.md @@ -2,8 +2,4 @@ 'astro': minor --- -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. +A trailing slash will not be automatically appended to `import.meta.env.SITE`. Instead, it will be the value of the `site` config as is. This may affect usages of `${import.meta.env.SITE}image.png`, which will need to be updated accordingly. From a12ec91f2fe2926baf38d2577c2830bcc90c40ee Mon Sep 17 00:00:00 2001 From: Junya Kono Date: Sun, 15 Jan 2023 18:34:32 +0900 Subject: [PATCH 3/3] fix: change semver --- .changeset/twelve-cooks-tickle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/twelve-cooks-tickle.md b/.changeset/twelve-cooks-tickle.md index c0f3cdbb29e9..bf1bf5b8af4c 100644 --- a/.changeset/twelve-cooks-tickle.md +++ b/.changeset/twelve-cooks-tickle.md @@ -1,5 +1,5 @@ --- -'astro': minor +'astro': major --- A trailing slash will not be automatically appended to `import.meta.env.SITE`. Instead, it will be the value of the `site` config as is. This may affect usages of `${import.meta.env.SITE}image.png`, which will need to be updated accordingly.