diff --git a/.changeset/large-bananas-prove.md b/.changeset/large-bananas-prove.md new file mode 100644 index 000000000..da3467950 --- /dev/null +++ b/.changeset/large-bananas-prove.md @@ -0,0 +1,5 @@ +--- +'@astrojs/image': patch +--- + +Fixes a bug that lost query parameters for remote images in the `` component diff --git a/packages/integrations/image/src/utils/paths.ts b/packages/integrations/image/src/utils/paths.ts index cd21da95d..556505704 100644 --- a/packages/integrations/image/src/utils/paths.ts +++ b/packages/integrations/image/src/utils/paths.ts @@ -18,7 +18,7 @@ export function extname(src: string) { return ''; } - return src.substring(src.length - (base.length - index)); + return base.substring(index); } function removeExtname(src: string) { @@ -32,7 +32,7 @@ function removeExtname(src: string) { } function basename(src: string) { - return src.replace(/^.*[\\\/]/, ''); + return removeQueryString(src.replace(/^.*[\\\/]/, '')); } export function propsToFilename(transform: TransformOptions) { diff --git a/packages/integrations/image/test/fixtures/basic-picture/src/assets/blog/introducing-astro.jpg b/packages/integrations/image/test/fixtures/basic-picture/src/assets/blog/introducing astro.jpg similarity index 100% rename from packages/integrations/image/test/fixtures/basic-picture/src/assets/blog/introducing-astro.jpg rename to packages/integrations/image/test/fixtures/basic-picture/src/assets/blog/introducing astro.jpg diff --git a/packages/integrations/image/test/fixtures/basic-picture/src/pages/index.astro b/packages/integrations/image/test/fixtures/basic-picture/src/pages/index.astro index 98aac062d..7cc20d65f 100644 --- a/packages/integrations/image/test/fixtures/basic-picture/src/pages/index.astro +++ b/packages/integrations/image/test/fixtures/basic-picture/src/pages/index.astro @@ -1,5 +1,6 @@ --- import socialJpg from '../assets/social.jpg'; +import introJpg from '../assets/blog/introducing astro.jpg'; import { Picture } from '@astrojs/image/components'; --- @@ -10,6 +11,8 @@ import { Picture } from '@astrojs/image/components';