linkapp.config.ts
Define match rules
hostnames(required) — domains your app supports. List every variant you expect (youtube.com,www.youtube.com,m.youtube.com, etc.).patterns— optional pathname/search combos that must match. Leave empty to match any path on the hostnames.notPatterns— optional exclusions, useful when matching a broad path with specific carve-outs.
Pattern syntax cheatsheet
Patterns use URLPattern semantics.| Pattern | Matches | Tip |
|---|---|---|
{ pathname: "/watch" } | https://youtube.com/watch | Exact path |
{ pathname: "/:id" } | https://youtu.be/abc123 | Named segment |
{ pathname: "/products/*" } | https://example.com/products/a/b | Wildcard suffix |
{ search: "v=:videoId" } | ?v=dQw4w9WgXcQ | Include both key and placeholder |
{ hostname: "m.youtube.com", pathname: "/watch" } | https://m.youtube.com/watch | Override host per pattern |
Test your rules
Use the CLI to confirm matches before shipping:package.json
Troubleshoot fast
- Double-check hostnames—include
www/mobile/regional variants explicitly. - Ensure named parameters keep the colon (
/user/:id, not/user/id). - Declare query parameters with both the key and placeholder (
search: "v=:videoId"). - Replace overly broad wildcards if you see unexpected matches.
Best practices
- Start specific, then add broader fallbacks (
/watchbefore/:id). - Document uncommon paths with inline comments for future maintainers.
- Keep the total number of patterns below the 50-pattern limit.
- Re-run
linkapp test-url-match-rulesafter every config change.