url-regex icon indicating copy to clipboard operation
url-regex copied to clipboard

Support not requiring tlds, passing in list on your own

Open osdiab opened this issue 6 years ago • 2 comments

  • the tlds library 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 strict is 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:

  1. add a separate entry point that doesn't include it, requires you to pass in a set of TLDs if you set strict to false, so that bundle-conscious clients can just include that instead
  2. somehow modify the existing library so that code-splitting-enabled clients can profit from the existing module export without breaking changes, while only loading tlds if necessary. not sure how that would work, I assume the previous suggestion is more realistic

osdiab avatar Oct 16 '19 09:10 osdiab

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.

osdiab avatar Oct 18 '19 04:10 osdiab

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).

niftylettuce avatar Aug 15 '20 07:08 niftylettuce