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: 377 Allow commas in urls on data-srcset #388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alvarosabu
Copy link

@alvarosabu alvarosabu commented Aug 1, 2019

Regarding #377

The previous code trimmed al the spaces and uses the commas to split, but urls can containn comas.

For example, Cloudinary (pretty use in the FE side) uses commas in their transformation paths like this:

https://res.cloudinary.com/alvarosaburido/image/upload/c_scale,q_auto,w_320/v1563876252/alvaro-saburido-portfolio.png

This solution will split a common srcset. The trimming is also done after it for each item so no problem about white spaces.

@alvarosabu
Copy link
Author

I found an error with it, I'm fixing it right now

@reganjohnson
Copy link

👍

@@ -66,12 +66,13 @@ function getBestSelectionFromSrcset (el, scale) {
const result = []
const container = el.parentNode
const containerWidth = container.offsetWidth * scale
const splitArg = options.includes(',\n') ? ',\n' : ', '
Copy link

@hsxfjames hsxfjames Nov 4, 2019

Choose a reason for hiding this comment

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

Should splitArg be /,\s+/ ?

Copy link
Author

Choose a reason for hiding this comment

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

I tried with /,\s+/ and ain't working. With the ,\n works fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the /,\s+/ does not work? /,\n/ is not very suitable.

@vin-ni
Copy link

vin-ni commented Nov 29, 2021

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants