mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-05-06 22:12:23 +08:00
fix: refine regex patterns for server directives (#1384)
Updated regular expressions to handle optional whitespace and comments.
This commit is contained in:
@@ -48,9 +48,9 @@ func scanForSite(configPath string, content []byte) error {
|
||||
}
|
||||
|
||||
// Regular expressions for server_name and listen directives
|
||||
serverNameRegex := regexp.MustCompile(`(?m)server_name\s+([^;]+);`)
|
||||
listenRegex := regexp.MustCompile(`(?m)listen\s+([^;]+);`)
|
||||
returnRegex := regexp.MustCompile(`(?m)return\s+30[1-8]\s+https://`)
|
||||
serverNameRegex := regexp.MustCompile(`(?m)^[ \t]*server_name\s+([^;#]+);`)
|
||||
listenRegex := regexp.MustCompile(`(?m)^[ \t]*listen\s+([^;#]+);`)
|
||||
returnRegex := regexp.MustCompile(`(?m)^[ \t]*return\s+30[1-8]\s+https://[^\s;#]+`)
|
||||
|
||||
// Find server blocks
|
||||
serverBlockRegex := regexp.MustCompile(`(?ms)server\s*\{[^\{]*((.*?\{.*?\})*?[^\}]*)\}`)
|
||||
|
||||
Reference in New Issue
Block a user