braintree / sanitize-url

MIT License
312 stars 35 forks source link

add check for module since it throws an error when library used witho… #8

Closed insanicly closed 5 years ago

insanicly commented 5 years ago

…ut a packaging app like browsify etc.

insanicly commented 5 years ago

module exports statement is giving error when you just want to use this as a javascript function.

crookedneighbor commented 5 years ago

This module is not intended to be used outside of a build environment.

The way you have it, you'll be adding the following variables onto the window:

invalidPrototcolRegex
ctrlCharactersRegex
urlSchemeRegex
relativeFirstCharacters
isRelativeUrl
sanitizeUrl

The only bit you're intending to add is sanitizeUrl.

We're not going to incorporate this into the repo, as this module is intended to be used within various Braintree npm modules. However, you are free to fork the repo and use it as a standalone script tag on your page. (I recommend wrapping the whole script in a function closure and attaching sanitizeUrl to the window explicitly to avoid leaking the other variables I mentioned above)

insanicly commented 5 years ago

I don't agree but ok. I already forked it.

thanks.