Closed jab closed 6 years ago
Thank you for reporting this issue.
I really like your suggestion of allowing an override to the webp regex. It'll be quite straightforward to implement and document, so expect a new release sometime tomorrow.
I've merged in a change, PR #39 , which adds the webpRegex
property as a way to override the default regex, updated the readme to reflect that and added a couple of basic tests in test/webp.html
The new release is 1.0.14
Tested the new web-regex API and looks like it's working great. Thanks for the quick fix and release!
No problem. Thanks again for reporting the issue and a great way to fix it.
It looks like the webp regex only matches webp image urls that end with
.webp
(src):But this fails to match valid webp image urls like
example.com/image.webp?v=1
or evenexample.com/image.webp?
.(click for aside)
Technically, the filename extension part of a url isn't even what determines the filetype, rather the mimetype specified in the `Content-Type` header of the response does. So even a url like `example.com/avatar` with no extension may very well be a webp image. In many cases, this is even the best design, e.g. when the requester doesn't / shouldn't need to know what the image type is, and only expects that there's some image at the requested path, letting the server tell it what the type is (possibly generated / decided dynamically). This design is less common than query params, and maybe more complex to support, in which case this may bear considering separately.)You could drop the `$` from the regex, but that would result in false positives like `/v2.webplatform.gif`. You could instead strip off any query string before testing against the regex, but let's back up a second. There's no reason `