diff --git a/_embed/templates/base.tmpl b/_embed/templates/base.tmpl
index 195cb73a..a4acf2e8 100644
--- a/_embed/templates/base.tmpl
+++ b/_embed/templates/base.tmpl
@@ -113,7 +113,7 @@
-
+
diff --git a/config/config.go b/config/config.go
index 5d6d9817..806a6716 100644
--- a/config/config.go
+++ b/config/config.go
@@ -26,6 +26,10 @@ type Config struct {
CurrentUser *User
}
+func (c Config) FullWebDavURL() string {
+ return c.AbsoluteURL + c.WebDavURL
+}
+
// Rule is a dissalow/allow rule
type Rule struct {
Regex bool
@@ -82,7 +86,7 @@ func Parse(c *caddy.Controller) ([]Config, error) {
cfg.BaseURL = strings.TrimPrefix(cfg.BaseURL, "/")
cfg.BaseURL = strings.TrimSuffix(cfg.BaseURL, "/")
cfg.BaseURL = "/" + cfg.BaseURL
- cfg.WebDavURL = cfg.BaseURL + "webdav"
+ cfg.WebDavURL = "webdav"
if cfg.BaseURL == "/" {
cfg.BaseURL = ""
@@ -230,17 +234,18 @@ func Parse(c *caddy.Controller) ([]Config, error) {
}
}
+ caddyConf := httpserver.GetConfig(c)
+ cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
+ cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
+ cfg.AbsoluteURL = strings.TrimSuffix(cfg.AbsoluteURL, "/")
+ cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/")
+ cfg.WebDavURL = "/" + strings.TrimPrefix(cfg.WebDavURL, "/")
cfg.Handler = &webdav.Handler{
Prefix: cfg.WebDavURL,
FileSystem: cfg.FileSystem,
LockSystem: webdav.NewMemLS(),
}
- caddyConf := httpserver.GetConfig(c)
- cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
- cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
- cfg.AbsoluteURL = strings.TrimSuffix(cfg.AbsoluteURL, "/")
- cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/")
if err := appendConfig(cfg); err != nil {
return configs, err
}
diff --git a/filemanager.go b/filemanager.go
index ddd03586..6336aa9b 100644
--- a/filemanager.go
+++ b/filemanager.go
@@ -64,7 +64,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
}
// Checks if the request URL is for the WebDav server
- if strings.HasPrefix(r.URL.Path, c.WebDavURL) {
+ if httpserver.Path(r.URL.Path).Matches(c.WebDavURL) {
// Checks for user permissions relatively to this PATH
if !user.Allowed(strings.TrimPrefix(r.URL.Path, c.WebDavURL)) {
return http.StatusForbidden, nil