url-regex
url-regex copied to clipboard
Support not requiring tlds, passing in list on your own
- the
tldslibrary bloats the bundle size of this library by a lot (6kb minified according to bundlephobia), most of which are irrelevant to almost all users of the library, and will increase over time as highlighted in #12 - it isn't even used at all by default, unless
strictis false - i'm happy as a client of the library to include a list of TLDs i consider valid, rather than deferring to the list
So I think there ought to be a way for one of two things to happen:
- add a separate entry point that doesn't include it, requires you to pass in a set of TLDs if you set
stricttofalse, so that bundle-conscious clients can just include that instead - somehow modify the existing library so that code-splitting-enabled clients can profit from the existing module export without breaking changes, while only loading
tldsif necessary. not sure how that would work, I assume the previous suggestion is more realistic
This commenter on https://github.com/sindresorhus/get-urls/pull/51#issuecomment-543381694 also has a use case - passing in .onion urls so that person can use it for Tor links.
This issue is fixed in my maintained and modern version of this package at https://github.com/niftylettuce/url-regex-safe. You should be able to switch from url-regex to url-regex-safe now. See the updated list of options as I added some new ones, and changed a few defaults to more sensible ones (since not everyone is parsing Markdown for instance).