ConfigProtect: Permit to obtain the list of files without initial /

This commit is contained in:
Daniele Rondina 2020-11-06 23:29:08 +01:00
parent b24d335538
commit 68bc8d4d27

View File

@ -91,18 +91,26 @@ func (c *ConfigProtect) Map(files []string) {
} }
nextFile: nextFile:
} }
} }
func (c *ConfigProtect) Protected(file string) bool { func (c *ConfigProtect) Protected(file string) bool {
if file[0:1] != "/" {
file = "/" + file
}
_, ans := c.MapProtected[file] _, ans := c.MapProtected[file]
return ans return ans
} }
func (c *ConfigProtect) GetProtectFiles() []string { func (c *ConfigProtect) GetProtectFiles(withSlash bool) []string {
ans := []string{} ans := []string{}
for key, _ := range c.MapProtected { for key, _ := range c.MapProtected {
if withSlash {
ans = append(ans, key) ans = append(ans, key)
} else {
ans = append(ans, key[1:])
}
} }
return ans return ans
} }