From dcec174b2af3af816180772f948575f896d58d20 Mon Sep 17 00:00:00 2001 From: bptato Date: Tue, 25 Jul 2023 22:10:28 +0200 Subject: Add compileMatchRegex This makes it so that host = 'example\.org' mandates an exact match, but host = '^example' matches example.org, example.com, etc. (Previously, 'example\.org' would have matched exampleexample.org as well, which was quite counter-intuitive.) --- doc/config.md | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'doc/config.md') diff --git a/doc/config.md b/doc/config.md index 443d7003..ccaa64ab 100644 --- a/doc/config.md +++ b/doc/config.md @@ -35,6 +35,8 @@ examples. * [Keybindings](#keybindings) * [Pager actions](#pager-actions) * [Line-editing actions](#line-editing-actions) +* [Appendix](#appendix) + * [Regex handling](#regex-handling) ## Start @@ -314,7 +316,9 @@ Omnirule options: match regex Regular expression used to match the input string. Note that websites -passed as arguments are matched as well. +passed as arguments are matched as well.
+Note: regexes are handled according to the [regex handling](#regex-handling) +rules. @@ -335,12 +339,12 @@ Examples: ``` # Enable cookies on the orange website for log-in. [[siteconf]] -url = '^https://news\.ycombinator\.com/.*' +url = 'https://news\.ycombinator\.com/.*' cookie = true # Redirect npr.org to text.npr.org. [[siteconf]] -host = '^(www\.)?npr\.org$' +host = '(www\.)?npr\.org' rewrite-url = ''' (x) => { x.host = "text.npr.org"; @@ -351,10 +355,10 @@ rewrite-url = ''' # Allow cookie sharing on *sr.ht domains. [[siteconf]] -host = '^.*sr\.ht$' +host = '.*sr\.ht' cookie = true share-cookie-jar = 'sr.ht' -third-party-cookie = '^.*\.sr.ht$' +third-party-cookie = '.*\.sr.ht' ``` Siteconf options: @@ -371,14 +375,18 @@ Siteconf options: url regex Regular expression used to match the URL. Either this or the `host` option -must be specified. +must be specified.
+Note: regexes are handled according to the [regex handling](#regex-handling) +rules. host regex Regular expression used to match the host part of the URL (i.e. domain -name/ip address.) Either this or the `url` option must be specified. +name/ip address.) Either this or the `url` option must be specified.
+Note: regexes are handled according to the [regex handling](#regex-handling) +rules. @@ -399,7 +407,9 @@ false for all websites. third-party-cookie regex/array of regexes Domains for which third-party cookies are allowed on this domain. Note: -this only works for buffers which share the same cookie jar. +this only works for buffers which share the same cookie jar.
+Note: regexes are handled according to the [regex handling](#regex-handling) +rules. @@ -876,3 +886,19 @@ as a word boundary. # Control+W deletes everything before the cursor until it reaches a space. 'C-w' = 'line.clearWord(x => x == " ")' ``` + +## Appendix + +### Regex handling + +Regular expressions are assumed to be exact matches, except when they start +with a caret (^) sign or end with an unescaped dollar ($) sign. + +In other words, the following transformations occur: + +``` +^abcd -> ^abcd +efgh$ -> efgh$ +^ijkl$ -> ^ijkl$ +mnop -> ^mnop$ +``` -- cgit 1.4.1-2-gfad0 22'>22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103