aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddyconfig/caddyfile
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-05-01 07:43:05 -0400
committerGitHub <[email protected]>2024-05-01 07:43:05 -0400
commitfeeb6af40334e6826a57a1a83cc62db672b9b023 (patch)
tree69f5366af40fd6017ff58789bc33bb7350c7632c /caddyconfig/caddyfile
parentd129ae6aec6af2182217ee8a235f4df8cd2bbfde (diff)
downloadcaddy-feeb6af40334e6826a57a1a83cc62db672b9b023.tar.gz
caddy-feeb6af40334e6826a57a1a83cc62db672b9b023.zip
httpcaddyfile: Fix expression matcher shortcut in snippets (#6288)
Diffstat (limited to 'caddyconfig/caddyfile')
-rw-r--r--caddyconfig/caddyfile/lexer.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/lexer.go b/caddyconfig/caddyfile/lexer.go
index 4db63749b..9b523f397 100644
--- a/caddyconfig/caddyfile/lexer.go
+++ b/caddyconfig/caddyfile/lexer.go
@@ -340,6 +340,8 @@ func (l *lexer) finalizeHeredoc(val []rune, marker string) ([]rune, error) {
return []rune(out), nil
}
+// Quoted returns true if the token was enclosed in quotes
+// (i.e. double quotes, backticks, or heredoc).
func (t Token) Quoted() bool {
return t.wasQuoted > 0
}
@@ -356,6 +358,19 @@ func (t Token) NumLineBreaks() int {
return lineBreaks
}
+// Clone returns a deep copy of the token.
+func (t Token) Clone() Token {
+ return Token{
+ File: t.File,
+ imports: append([]string{}, t.imports...),
+ Line: t.Line,
+ Text: t.Text,
+ wasQuoted: t.wasQuoted,
+ heredocMarker: t.heredocMarker,
+ snippetName: t.snippetName,
+ }
+}
+
var heredocMarkerRegexp = regexp.MustCompile("^[A-Za-z0-9_-]+$")
// isNextOnNewLine tests whether t2 is on a different line from t1