jcubic / wayne

Service Worker Routing library for in browser HTTP requests
https://jcubic.github.io/wayne
MIT License
556 stars 29 forks source link

Fix to FileSystem middleware to properly handle binary files. #25

Closed claudiosdc closed 1 year ago

claudiosdc commented 1 year ago

This fixes an issue retrieving binary resources (e.g. image file) caused by incorrectly handling them as UTF-8 strings.

jcubic commented 1 year ago

Thanks for the fix, but I will need to test with Unicode characters if will work. And since there are no unit tests, I need to do this by hand.

claudiosdc commented 1 year ago

Thanks for the fix, but I will need to test with Unicode characters if will work. And since there are no unit tests, I need to do this by hand.

Yes, this should work for any data type. The data is always treated as binary. The MIME type is then used to inform the data type so the client can correctly handle it.