kytta / shareon

📯 Lightweight, stylish, and ethical share buttons for popular social networks
https://shareon.js.org/
MIT License
465 stars 25 forks source link

Refactor URL builder #61

Open kytta opened 1 year ago

kytta commented 1 year ago

As discovered while trying to implement a new parameter, our URL building is not ideal. In this particular case, we URL-encode stuff twice: when we pass parameters to the builder and then in the builders themselves.

Most share pages use URL parameters, so wouldn't it be better for each social network to only define its main URL along with the needed parameters? Then, we can take the built-in URL and URLSearchParams to build the final URL.

A while ago, Dario did a similar thing, also adding a lot of other stuff. Since then, Shareon lost TypeScript, switched bundlers, heck, even the default branch is different. It might make more sense to re-implement this.

It is very important that the final size remains as small as possible, ideally under 1 kB for the ESM bundle. Use pnpm test to build and test for size. See also https://github.com/kytta/shareon/issues/62

kytta commented 1 year ago

An important note: This issue is blocked by pretty much every other issue. Using URL and URLSearchParams is a potentially breaking change, and I want to add support for as many new buttons as possible before finally releasing v3