mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-06-19 07:36:59 +00:00
fix: remove redundant HasPrefix check in isConfigFilePath
The first operand strings.HasPrefix(lowerRelativePath, sep+pattern+sep) was dead code because the strings.Contains check above already covers this case - if a string starts with X, it necessarily contains X. Simplified to only check HasPrefix(lowerRelativePath, pattern+sep) which adds meaningful coverage for paths starting with the pattern directly after the config root.
This commit is contained in:
Vendored
+3
-1
@@ -373,7 +373,9 @@ func isConfigFilePath(filePath string) bool {
|
||||
return true
|
||||
}
|
||||
// Check if path starts with this directory name (after config root)
|
||||
if strings.HasPrefix(lowerRelativePath, sep+pattern+sep) || strings.HasPrefix(lowerRelativePath, pattern+sep) {
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user