-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: image proxy not working correctly (#9659)
* fix: image proxy not working correctly * fix: only take in valid images * test: add tests * Create slimy-mayflies-vanish.md * nit: remove erika-ism
- Loading branch information
1 parent
1bf0ddd
commit 39050c6
Showing
18 changed files
with
129 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
Fix Astro wrongfully deleting certain images imported with `?url` when used in tandem with `astro:assets` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/core-image-deletion/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@test/core-image-deletion", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
}, | ||
"scripts": { | ||
"dev": "astro dev" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.3 KB
packages/astro/test/fixtures/core-image-deletion/src/assets/onlyone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.4 KB
packages/astro/test/fixtures/core-image-deletion/src/assets/twoofus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/core-image-deletion/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
import { Image } from "astro:assets"; | ||
import onlyOne from "../assets/onlyone.jpg"; | ||
import twoOfUs from "../assets/twoofus.jpg"; | ||
import twoFromURL from "../assets/url.jpg"; | ||
import twoFromURL_URL from "../assets/url.jpg?url"; | ||
--- | ||
|
||
<Image src={onlyOne} alt="Only one of me exists at the end of the build" /> | ||
|
||
<Image src={twoOfUs} alt="Two of us will exist, because I'm also used as a normal image" /></Image> | ||
<img src={twoOfUs.src} alt="Two of us will exist, because I'm also used as a normal image" /> | ||
|
||
<Image src={twoFromURL} alt="Two of us will exist, because I'm also imported using ?url" /></Image> | ||
<img src={twoFromURL_URL} alt="Two of us will exist, because I'm also used as a normal image" /> |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/core-image-deletion/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "astro/tsconfigs/base", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/assets/*": ["src/assets/*"] | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect } from 'chai'; | ||
import { testImageService } from './test-image-service.js'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('astro:assets - delete images that are unused', () => { | ||
/** @type {import('./test-utils.js').Fixture} */ | ||
let fixture; | ||
|
||
describe('build ssg', () => { | ||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/core-image-deletion/', | ||
image: { | ||
service: testImageService(), | ||
}, | ||
}); | ||
|
||
await fixture.build(); | ||
}); | ||
|
||
it('should delete images that are only used for optimization', async () => { | ||
const imagesOnlyOptimized = await fixture.glob('_astro/onlyone.*.*'); | ||
expect(imagesOnlyOptimized).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should not delete images that are used in other contexts', async () => { | ||
const imagesUsedElsewhere = await fixture.glob('_astro/twoofus.*.*'); | ||
expect(imagesUsedElsewhere).to.have.lengthOf(2); | ||
}); | ||
|
||
it('should not delete images that are also used through query params', async () => { | ||
const imagesUsedElsewhere = await fixture.glob('_astro/url.*.*'); | ||
expect(imagesUsedElsewhere).to.have.lengthOf(2); | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.