-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle srcset local image paths with spaces (#9537)
* fix: handle srcset local image paths with spaces * replaced janky 'replaceAll' with encodeURI * Update .changeset/weak-oranges-relate.md Co-authored-by: Florian Lefebvre <[email protected]> * fix: encodeURI the returned filepath directly --------- Co-authored-by: Florian Lefebvre <[email protected]> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Princesseuh <[email protected]>
- Loading branch information
1 parent
3834c12
commit 16e61fc
Showing
5 changed files
with
34 additions
and
2 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 | ||
--- | ||
|
||
`<Image />` srcset now parses encoded paths correctly |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/core-image-ssg/src/pages/srcset.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,14 @@ | ||
--- | ||
import { Image } from "astro:assets"; | ||
import imageWithSpaces from "../assets/image 1.jpg"; | ||
--- | ||
|
||
<div id="local-2-widths-with-spaces"> | ||
<!-- | ||
In this example, only two images should be generated : | ||
- The base image | ||
- The 2x image | ||
Additionally, the image URL should be encoded to avoid issues with spaces and other special characters. | ||
--> | ||
<Image src={imageWithSpaces} width={imageWithSpaces.width / 2} widths={[imageWithSpaces.width]} alt="" /> | ||
</div> |