kutt icon indicating copy to clipboard operation
kutt copied to clipboard

Support extended URL and deep link schemes in regex matcher -Update v…

Open mskayali opened this issue 8 months ago • 0 comments

validators.handler.js updated

This PR updates the regex used for URL/deep link validation to handle a wider range of schemes, including:

  • Standard web protocols: http://, https://, ftp://
  • Custom app deep links: e.g. com.example.app://action=authorization&hash=testKey&user=1
  • Non-slash schemes: e.g. mailto:[email protected], file:/Users/me/file.txt

The new regex is:

^[a-zA-Z][a-zA-Z0-9.+-]*:(\/\/)?[^\s]+

Motivation

Previously, the regex excluded common schemes (http, https, ftp) and only partially supported custom protocols. This caused valid links such as iOS deep links or mailto: addresses to be rejected.

By expanding the pattern:

  • Developers can reliably validate both standard URLs and deep links.
  • Edge cases like dotted custom schemes (com.example.app) and plus/minus variants (custom+scheme-1) are fully supported.
  • Optional // handling ensures compatibility with schemes that do not use slashes.

Examples

Now valid:

  • http://example.com
  • https://secure.com
  • ftp://fileserver
  • com.exaple.app://action=authorization&hash=testKey&user=1
  • mailto:[email protected]
  • file:/Users/me/file.txt

Still invalid:

  • ://oops
  • justastring
  • 123abc://test

Testing

  • Added unit tests for all supported schemes and edge cases.
  • Confirmed backwards compatibility for existing deep links.

mskayali avatar Aug 14 '25 13:08 mskayali