Skip to content

Commit

Permalink
Add better explanation for '^' in patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
remusao committed Jun 23, 2022
1 parent 33dc06f commit 62d5eb5
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions goggles/quickstart.goggle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,35 @@
/this/is/*/pattern

! The special character '^' can be used to indicate that an URL delimiter such
! as '/' or end-of-url can be matched (note: the number of carets allowed in a
! given instruction is limited):
! as '/' or end-of-url can be matched. More specifically, '^' is equivalent to
! the regexp: [^\w\d._%-]|$
!
! This means that it can match either the end of the URL or any character that is
! not a letter, digit, dot, underscore, percent sign or dash. Here are a few
! examples of characters that are matched by '^': / (slash), = (equal),
! [ (bracket), : (colon), etc.
!
! In practice, you will usually want to use '/' (or any other specific
! separator like '=' or '?') most of the time in your patterns, except at the end
! of a pattern in cases where you want to be a little bit more generic, and
! express that your pattern should be either matching at the end of the URL or be
! followed by a separator and then arbitrary URL components.
!
! For example, |https://example.org^ will match: 'https://example.org',
! 'https://example.org/' or 'https://example.org/path'; but it will *not* match
! 'https://example.org.ac', which is also a valid domain name starting with
! 'https://example.org'.
!
! Another example, /foo.js^ will match: 'https://example.org/foo.js',
! 'https://example.org/foo.js?param=42', 'https://example.org/foo.js/' but it
! will *not* match 'https://example.org/foo.jsx' (because it is not followed by a
! separator).
!
! Also note that the maximum number of carets allowed in a given instruction is
! limited.
/this/is/a/pattern^
|https://example.org^
/foo.js^

! By default, a pattern can match anywhere in the URL, but there are specific
! characters which can be used to indicate prefix or suffix matches: we call them
Expand Down

0 comments on commit 62d5eb5

Please sign in to comment.