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: encode spaces when generating srcset #7340

Merged
merged 11 commits into from
Jun 22, 2023
Merged

fix: encode spaces when generating srcset #7340

merged 11 commits into from
Jun 22, 2023

Conversation

wooseopkim
Copy link
Contributor

Changes

Failed parsing 'srcset' attribute value since it has an unknown descriptor.
Dropped srcset candidate "/_astro/HELLO"

Testing

  • packages/integrations/image/test/picture-ssg.test.js
  • packages/integrations/image/e2e/picture.test.js
    • Is it okay to duplicate the whole basic-picture fixture?

Docs

  • Fixed bug in Picture and getPicture with space characters in filenames.

@changeset-bot
Copy link

changeset-bot bot commented Jun 8, 2023

🦋 Changeset detected

Latest commit: 57af68b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jun 8, 2023
@@ -85,7 +85,7 @@ export async function getPicture(params: GetPictureParams): Promise<GetPictureRe
image = img;
}

return `${img.src} ${width}w`;
return `${img.src?.replaceAll(' ', '%20')} ${width}w`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK encoding the whole img.src was not required. I've tested the filename @withastro:안녕하세요🚀+❤.jpg which contains an emoji, URI reserved characters, and Korean chracters but it seemed okay before (and also after) applying this.

@Princesseuh
Copy link
Member

Princesseuh commented Jun 9, 2023

The code looks great to me (feel free to use encodeUri though if it does fix the problem, that way we're fully covered!), however the testing strategy is very heavy-handed and we've been trying to improve our testing strategy recently.

I'd suggest not using a full E2E test for this and instead just adding a test to this file: https://github.com/withastro/astro/blob/main/packages/integrations/image/test/picture-ssg.test.js

@wooseopkim
Copy link
Contributor Author

@Princesseuh Yeah, agreed and understood. Actually I've also updated test/picture-ssg.test.js. In this case, would it be enough to delete the e2e directory?

@bluwy
Copy link
Member

bluwy commented Jun 11, 2023

I think we can remove playwright entirely with the new test. I'm also slightly leaning towards encodeUri as the more correct way of handling this

@bluwy bluwy merged commit 9739adc into withastro:main Jun 22, 2023
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getPicture may generate invalid srcset values after SSR
4 participants