badge-size
badge-size copied to clipboard
Use raw buffer to parse files
- Resolves https://github.com/ngryman/badge-size/issues/94, resolves #16.
- Update got to transfer
.png
using the raw buffer — now it works again! - Fix the version number of target URL in 'broken absolute' test case.
- Use nock to mock large file requests in tests.
- Always use GET method.
The main cause of #94 is unpkg (or the whole cloudflare, not sure) doesn't reply Content-Length
anymore. Considering Content-Length
isn't a reliable header nowadays, this PR enables badge-size to actually download almost all required files, which may significantly increase the bandwidth usage. Thus I implemented #16 at the same time.
The download threshold temporarily being set to 5 megabytes.
We have to find the best threshold before this is merged. 🤔
Demo: https://badge-size-teal.vercel.app/
Hey @PaperStrike, thanks for the PR 🙌
I'm currently moving house, hence the delay in my answer, sorry about that.
I would need to think about the implications of dropping the HEAD
HTTP method. Currently, the service already costs me quite a bit of 💰 and I'm concerned that downloading every file's payload would drastically increase my bills 😬
I'll probably dive into this during the course of this month. I might also consider an alternative of Vercel for hosting this project to reduce the costs.
It is worth to mention that if the raw sizes of files in npm packages matter significantly (I have no idea the amount of these users), we can try to read them from unpkg's official ?meta
, or/and jsDelivr's official data.jsdelivr.com service. It's more reliable and faster.
👋 Sorry for the lack of news.
Just a heads up that I've started a Rust implementation in the #rust branch.
It should improve a bunch of things. It's not relying on shields.io
anymore so it should be more performant as well 🚀
I would like to switch to it during the next month of so 🤞
Alright, I have the Rust version running. Could you take a look at https://github.com/ngryman/badge-size/pull/100? If everything goes well, I expect to push it to production by EOW. Thanks!