aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/fileserver/staticfiles.go
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-11-13 03:55:51 -0500
committerGitHub <[email protected]>2024-11-13 03:55:51 -0500
commit315715e90ffa25c4ad0d8a96e828dbdf6f638583 (patch)
tree3b22815c57acc730c90b6dcaa740a34a7073a36b /modules/caddyhttp/fileserver/staticfiles.go
parent238f1108e6600049d9041abc88db24526ee4f882 (diff)
downloadcaddy-315715e90ffa25c4ad0d8a96e828dbdf6f638583.tar.gz
caddy-315715e90ffa25c4ad0d8a96e828dbdf6f638583.zip
core: Implement FastAbs to avoid repeated os.Getwd calls (#6687)
* core: Implement FastAbs to avoid repeated os.Getwd calls * Lint * Rename files
Diffstat (limited to 'modules/caddyhttp/fileserver/staticfiles.go')
-rw-r--r--modules/caddyhttp/fileserver/staticfiles.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go
index 4ae69b647..2b0caecfc 100644
--- a/modules/caddyhttp/fileserver/staticfiles.go
+++ b/modules/caddyhttp/fileserver/staticfiles.go
@@ -204,7 +204,7 @@ func (fsrv *FileServer) Provision(ctx caddy.Context) error {
// absolute paths before the server starts for very slight performance improvement
for i, h := range fsrv.Hide {
if !strings.Contains(h, "{") && strings.Contains(h, separator) {
- if abs, err := filepath.Abs(h); err == nil {
+ if abs, err := caddy.FastAbs(h); err == nil {
fsrv.Hide[i] = abs
}
}
@@ -636,7 +636,7 @@ func (fsrv *FileServer) transformHidePaths(repl *caddy.Replacer) []string {
for i := range fsrv.Hide {
hide[i] = repl.ReplaceAll(fsrv.Hide[i], "")
if strings.Contains(hide[i], separator) {
- abs, err := filepath.Abs(hide[i])
+ abs, err := caddy.FastAbs(hide[i])
if err == nil {
hide[i] = abs
}
@@ -655,7 +655,7 @@ func fileHidden(filename string, hide []string) bool {
}
// all path comparisons use the complete absolute path if possible
- filenameAbs, err := filepath.Abs(filename)
+ filenameAbs, err := caddy.FastAbs(filename)
if err == nil {
filename = filenameAbs
}