mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-06-19 07:36:59 +00:00
fix: remove dead HasPrefix branch in config dir pattern matching
The strings.HasPrefix(lowerRelativePath, pattern+sep) check was dead code because relativePath always starts with a path separator after TrimPrefix from a filepath.Clean'd configRoot. Since pattern values like 'sites-available' don't start with '/', HasPrefix with 'pattern+sep' (e.g., 'sites-available/') could never match a path starting with '/sites-available/'. The Contains(lowerRelativePath, sep+pattern+sep) check already correctly handles this case since it looks for '/pattern/' anywhere in the path.
This commit is contained in:
Vendored
+3
-7
@@ -368,16 +368,12 @@ func isConfigFilePath(filePath string) bool {
|
||||
// are typically config files. Use separator-bounded matching to avoid false positives
|
||||
// like "myconf.db" matching "conf.d" across the name/extension boundary
|
||||
for _, pattern := range configDirPatterns {
|
||||
// Check if pattern appears in the middle of path (with slashes on both sides)
|
||||
// Check if pattern appears in the path (with slashes on both sides)
|
||||
// This covers both middle-of-path and start-of-path cases since relativePath
|
||||
// always starts with a separator after TrimPrefix from a Clean'd configRoot
|
||||
if strings.Contains(lowerRelativePath, sep+pattern+sep) {
|
||||
return true
|
||||
}
|
||||
// Check if path starts with this directory name (after config root)
|
||||
// Note: We only check pattern+sep here because sep+pattern+sep is already covered
|
||||
// by the Contains check above (if a string starts with X, it contains X)
|
||||
if strings.HasPrefix(lowerRelativePath, pattern+sep) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Files with .conf extension are config files
|
||||
|
||||
Reference in New Issue
Block a user