braintree / sanitize-url

MIT License
321 stars 37 forks source link

Overly high JS baseline requirement, from using URL.canParse() #78

Open Tristan971 opened 3 months ago

Tristan971 commented 3 months ago

Hello,

In here, the library has begun using URL.canParse():

https://github.com/braintree/sanitize-url/blame/cdd33eb72e9f56eff7b3c49f1c5ed133838b9956/src/index.ts#L24

This imposes a surprisingly strict requirement on browser versions (https://caniuse.com/?search=canParse):

As far as I can tell, it has as a result only been widely available since ~ December 2023.

I don't mind it necessarily, but it is a huge enough jump that I'd suggest making it in a major version update.

I'm not sure what the previous minimal browser version set was exactly, but at least up to iOS 14 worked, going by the browsers we had successfully tested on our own website.

akphi commented 3 months ago

though rather unrelated, I would like to mention that this makes testing with Jest a little less convenient since URL.canParse is not implemented in jsdom

erquhart commented 2 months ago

This also breaks compatibility with React Native. I realize this was to address a security issue, but it's also a breaking change in a minor release, and should be reverted for that reason alone.

Related PR: https://github.com/braintree/sanitize-url/pull/77

cc/ @ibooker

ibooker commented 2 months ago

Hello, @Tristan971 Thanks for reporting this issue with URL.canParse(). We'll take a closer look at this issue. (Internal Tracking: BTWEB-171)

@erquhart We do not specifically support compatibility with React Native. If you can provides some details about what no longer works, we can better understand if its something we can address.

erquhart commented 2 months ago

@ibooker I don't see anything in the repo stating explicit support for any platform, browser etc., I'm just adding React Native to the list of environments for which this library no longer works.

I don't have a separate issue to outline, just that the use of URL.canParse() is not supported in React Native, as well as a fair amount of browser versions and jsdom, as mentioned by others.