Edit this page

API URL patterns

Some Unpoly features like a[up-alias] let you match any URL with a given pattern.

For this matching Unpoly does not use regular expressions, but the URL pattern format outlined below.

Matching an exact URL

Pass any absolute path or fully qualified URL to only match this exact value:


Matching with wildcards

Append an asterisk (*) to any path to match all URLs with that prefix:


Prepend an asterisk to match all URLs with that suffix:


You may also infix an asterisk to match URLs with the given prefix and suffix:


Matching one of multiple alternatives

To match one of multiple URLs or patterns, separate the alternatives by a space.

The following will match either /users/123 or /account:

/users/* /account

JavaScript functions that take URL patterns will accept multiple patterns as either a space-separated string or as an array of patterns:

up.layer.open({ acceptLocation: '/users/* /account' })
up.layer.open({ acceptLocation: ['/users/*', '/account'] })

Excluding patterns

To exclude an URL or pattern, prefix with a minus.

The following will match /users/alice but not /users/new:

/users/* -/users/new

Capturing named segments

It is sometimes useful to capture the value of a wildcard match, e.g. to close an overlay once a location is reached.

The following will capture { name: 'alice' } from the path /users/alice:


To only match digits (0-9), use the dollar symbol:

This website uses cookies to improve usability and analyze traffic.
I accept or learn more