-
Notifications
You must be signed in to change notification settings - Fork 869
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
base: master
Are you sure you want to change the base?
Conversation
I found an error with it, I'm fixing it right now |
👍 |
@@ -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' : ', ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should splitArg
be /,\s+/
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
+1 |
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.