-
Notifications
You must be signed in to change notification settings - Fork 355
Ticapix/fix srcset discovery #353
Ticapix/fix srcset discovery #353
Conversation
Any update if this PR will be merged ? |
Hi @ticapix! Sorry about the slow response here. I've never encountered a |
Thanks for looking into it. |
Hmm well, the way I read that spec, we can only have "zero or one" of a width descriptor or a pixel density descriptor. I absolutely agree that simplecrawler shouldn't get too bogged down in HTML standards if we see a different syntax being used in the wild, but it's also unnecessary to support an invalid syntax if it's not being widely used. Do you know some places where it is being used? |
test/discovery.js
Outdated
var links = | ||
discover("<img src='pic-200.png' srcset='pic-200.png 200px, pic-400.png 400w'>", { | ||
discover("<img src='pic.png' srcset='pic-200.png, pic-400.png 400w, pic-800.png 800w 2x'>", { |
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.
Could we remove 800w
towards the end of this line? As we discussed previously, I don't think the spec permits two descriptors there, so it would be better to not make that part of the test suite (even if the new implementation would unofficially support that syntax)
I had another look at the diff here, and I don't see any harm in the changes you propose to |
should be good now. |
Thanks, @ticapix! |
What this PR changes
changed the default discovery function to properly detect srcset url according to the specs
Rationale
srcset discovery function wasn't parsing correctly url with zero or more than 2 args.
Added a test as an exemple.