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

Add removeOriginalExtension option #158

Merged

Conversation

aszx87410
Copy link
Contributor

This PR add a new option called removeOriginalExtension.

When images converted to WebP on the fly, .webp was append to the filename. For example, test.png became test.png.webp. If you want to have only one filename extension like test.webp, you can set this option to true.

The motivation is because for some CDN services(like Azure CDN), it decides response header content-type by filename and it failed to recognize multiple filename extensions like .png.webp, so the content-type will be default value which is application/octet-stream.

There is no option to disable this behavior for now so I purpose this PR. Please let me know if there is any problem, and thanks for making this awesome library 😄

@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #158 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #158   +/-   ##
=======================================
  Coverage   88.42%   88.42%           
=======================================
  Files          13       13           
  Lines         190      190           
  Branches       46       46           
=======================================
  Hits          168      168           
  Misses         16       16           
  Partials        6        6           
Impacted Files Coverage Δ
lib/config.js 100.00% <ø> (ø)
lib/loaders/webp-loader.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d570274...81d2262. Read the comment docs.

@aszx87410 aszx87410 force-pushed the add-keep-original-extension-option branch from 580620b to 81d2262 Compare May 28, 2020 09:49
@cyrilwanner
Copy link
Owner

Thank you very much for this contribution!
Adding that option makes sense, I may even make this the default one with the next major version.

Will publish this change to npm as a patch in a few minutes.

@cyrilwanner cyrilwanner merged commit b10dd27 into cyrilwanner:master May 31, 2020
@aszx87410 aszx87410 deleted the add-keep-original-extension-option branch June 1, 2020 02:49
@aszx87410
Copy link
Contributor Author

Thanks for the promptly response and the new patch, I am glad to contribute. And I want to add one thing I mentioned above about content type. I upgrade my project today and turns out the Azure CDN still can't recognize the file with .webp extension, so I think maybe it's more about uploading issue, not about filename extension.

Anyway, I think it's still great to add this option to keep filename pure. Thanks for the quick response again!

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.

2 participants