Update examples to not combine density and width#12
Update examples to not combine density and width#12sindresorhus merged 2 commits intosindresorhus:mainfrom
Conversation
Hey, thanks for making this library! sindresorhus#6 updated the codebase to not allow density and width when parsing. (Although, amusingly, it does still allow it when stringifying - kind of the opposite of the robustness principle.) This updates the readme to match so that the examples are correct and parse-able. On a related note, would you be interested in another PR to make stringifying more strict? Also, what about a not-strict mode that does it's best and doesn't throw errors? (It would be handy for my use-case. For the moment I'm just wrapping this in a try/catch and using the original value if it throws.)
Sure
What's the use-case? |
I made a web proxy so that if you're on a filtered internet connection, you can give the proxy a url and it will go fetch the contents and rewrite all of the links and images and whatnot to go through the proxy. It mostly gets used by kids in school, but I have seen some more "legitimate" use - e.g. people Turkey or Iran bypassing their government's filters, or people who were traveling and needed to get around GeoIP restrictions. It previously used regex's to rewrite everything, but I've been rebuilding it to use a proper html parser, and I grabbed this library to parse srcsets and rewrite the urls. But I don't really care if the attribute is valid or not, that's the responsibility of the original website, not my proxy. So I'd prefer a "loose" mode that just did it's best and never threw any errors. This is what I have right now: |
|
PR welcome for a loose mode. |
Hey, thanks for making this library!
PR #6 updated the codebase to not allow
densityandwidthto be combined when parsing. (Although, amusingly, it does still allow it when stringifying - kind of the opposite of the robustness principle.)This updates the readme to match so that the examples are correct and parse-able.
On a related note, would you be interested in another PR to make stringifying more strict? Also, what about a not-strict mode that does it's best and doesn't throw errors? (It would be handy for my use-case. For the moment I'm just wrapping this in a try/catch and using the original value if it throws.)