Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

mskayali
Copy link

@mskayali mskayali commented Aug 14, 2025

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:user@example.com, 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:user@example.com
  • 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.

…alidators.handler.js

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:user@example.com`, `file:/Users/me/file.txt`

The new regex is:

```regex
^[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:user@example.com`
* `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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.