Skip to content
Madis Liias edited this page Sep 21, 2024 · 5 revisions

URL Patterns

URL contains of scheme://domain/path?query#fragment. (No basic auth user:password or port support at this point. Could extend domain to user:password@host:port in future. Let me know if you need that)

We match them with home-made pattern format (always a good idea, right!), based vaguely on globs and Ant Patterns. It is not thoroughly tested and can contain bugs. Please report if you find any. Also please report if it's not powerful enough and what would you want to do.

Pattern wildcards:

  • domain, path and query accepts * for single component (exactly one) and ** for all (zero or more) components
    • domain components are a.b.c
    • path components are a/b/c
    • query components are a&b&c
  • scheme and fragment accept *

Examples:

  • "github.com" matches any scheme, exact domain github.com, any path, any query and any fragment. Same as *://github.com/**.
  • "https://github.com" matches exact scheme https, exact domain github.com any path, any query and any fragment. Same as https://github.com/**.
  • "github.com/Browsers-software" matches any scheme, exact domain github.com, exact path /Browsers-software, any query and any fragment. Same as *://github.com/Browsers-software/.
  • "github.com/Browsers-software/**" matches any scheme, exact domain github.com, any path starting with /Browsers-software/ any query and any fragment. Same as *://github.com/Browsers-software/**.
  • "https://github.com/**/end" matches exact scheme https, exact domain github.com, any path ending with /end, any query and any fragment.
  • "https://github.com/" matches exact scheme https, exact domain github.com, exact path /, any query and any fragment.
  • "https://github.com/?#" matches exact scheme https, exact domain github.com, exact path /, empty query and empty fragment .

You can't differentiate between exact url https://github.com without the trailing / and https://github.com/ with the trailing /. But I also don't see a use-case for that.

More examples for domains:

  • *.youtube.com matches <subdomain>.youtube.com
  • **.youtube.com matches youtube.com, <subdomain>.youtube.com and <subdomain>.<subdomain>.youtube.com etc
  • **.youtube.* matches same as previous but with any top-level-domain
Clone this wiki locally