From 68bc8d4d27f1ee8963594a104d2ec4f8b80233e8 Mon Sep 17 00:00:00 2001 From: Daniele Rondina Date: Fri, 6 Nov 2020 23:29:08 +0100 Subject: [PATCH] ConfigProtect: Permit to obtain the list of files without initial / --- pkg/config/config_protect.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/config/config_protect.go b/pkg/config/config_protect.go index c287bf78..27ddc51e 100644 --- a/pkg/config/config_protect.go +++ b/pkg/config/config_protect.go @@ -91,18 +91,26 @@ func (c *ConfigProtect) Map(files []string) { } nextFile: } + } func (c *ConfigProtect) Protected(file string) bool { + if file[0:1] != "/" { + file = "/" + file + } _, ans := c.MapProtected[file] return ans } -func (c *ConfigProtect) GetProtectFiles() []string { +func (c *ConfigProtect) GetProtectFiles(withSlash bool) []string { ans := []string{} for key, _ := range c.MapProtected { - ans = append(ans, key) + if withSlash { + ans = append(ans, key) + } else { + ans = append(ans, key[1:]) + } } return ans }