jamdotdev / jam-dev-utilities

Lightweight utils set - fast and open-source. It's got cmd+k search & everything's client-side. No ads, your data stays local.
https://jam.dev/utilities
GNU General Public License v3.0
193 stars 19 forks source link

Bug? URL encoder won't encode URLs #55

Closed petergerard closed 3 weeks ago

petergerard commented 3 weeks ago

I'm noticing odd behavior with the URL Encoder.

If I want to encode a URL so I can use it in a query parameter, I can't get it to work.

I noticed that if I put in https:// it correctly encodes to https%3A%2F%2F, however if I add any more characters (e.g. https://google.com/ or https://g) it no longer encodes the colon or slashes and just leaves the text as-is.

It seems like perhaps it is detecting that the entered text is a URL and then deciding not to encode colons or slashes, since other characters (like %) are still encoded.

This is confusing and makes the tool not helpful for one of my primary use-cases - encoding a URL to use it as a query parameter in another URL. If there's an intentional reason for this behavior, it would be nice if it were optional.

peckz commented 3 weeks ago

@petergerard You are right, it was my opinionated approach, it conditionally uses encodeURI() and encodeURIComponent(). I will make a quick fix and make it always to encode full string, and later add those features as optional. Thanks for reporting!

peckz commented 3 weeks ago

@petergerard Thanks for reporting, new version is deployed!

image