diff --git a/_embed/templates/base.tmpl b/_embed/templates/base.tmpl index df68bcd7..01c28bac 100644 --- a/_embed/templates/base.tmpl +++ b/_embed/templates/base.tmpl @@ -14,7 +14,7 @@ diff --git a/assets/binary.go.REMOVED.git-id b/assets/binary.go.REMOVED.git-id index 9393f263..e321474a 100644 --- a/assets/binary.go.REMOVED.git-id +++ b/assets/binary.go.REMOVED.git-id @@ -1 +1 @@ -407ca3a29b2bf1bf0e7fb611b732dffd77ed0083 \ No newline at end of file +4c7f54809aade704e88ae32c81a1287cdbe7c7dc \ No newline at end of file diff --git a/config/commands.go b/config/commands.go index 80eedd60..60c3b881 100644 --- a/config/commands.go +++ b/config/commands.go @@ -36,7 +36,7 @@ func CommandRunner(c *caddy.Controller) (CommandFunc, error) { } fn = func(r *http.Request, c *Config, u *User) error { - path := strings.Replace(r.URL.Path, c.BaseURL+c.WebDavURL, "", 1) + path := strings.Replace(r.URL.Path, c.WebDavURL, "", 1) path = u.Scope + "/" + path path = filepath.Clean(path) diff --git a/config/config.go b/config/config.go index d6124bb1..68795b23 100644 --- a/config/config.go +++ b/config/config.go @@ -31,6 +31,11 @@ func (c Config) AbsoluteURL() string { return c.PrefixURL + c.BaseURL } +// AbsoluteWebdavURL ... +func (c Config) AbsoluteWebdavURL() string { + return c.PrefixURL + c.WebDavURL +} + // Rule is a dissalow/allow rule type Rule struct { Regex bool @@ -88,7 +93,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 = "webdav" + cfg.WebDavURL = "" if cfg.BaseURL == "/" { cfg.BaseURL = "" @@ -234,12 +239,16 @@ func Parse(c *caddy.Controller) ([]Config, error) { } } + if cfg.WebDavURL == "" { + cfg.WebDavURL = "webdav" + } + caddyConf := httpserver.GetConfig(c) cfg.PrefixURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") cfg.WebDavURL = "/" + strings.TrimPrefix(cfg.WebDavURL, "/") cfg.Handler = &webdav.Handler{ - Prefix: cfg.BaseURL + cfg.WebDavURL, + Prefix: cfg.WebDavURL, FileSystem: cfg.FileSystem, LockSystem: webdav.NewMemLS(), } diff --git a/filemanager.go b/filemanager.go index ab508eae..e4325c97 100644 --- a/filemanager.go +++ b/filemanager.go @@ -60,7 +60,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err } // Checks if the request URL is for the WebDav server - if httpserver.Path(r.URL.Path).Matches(c.BaseURL + 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 diff --git a/page/version.go b/page/version.go index cb435dec..2c81d95c 100644 --- a/page/version.go +++ b/page/version.go @@ -1,5 +1,5 @@ package page -var GIT_COMMIT_HASH = "37b14d6" +var GIT_COMMIT_HASH = "e46a007" var CIRCLE_BUILD_NUM = "" -var GENERATED int64 = 1492007757358403000 +var GENERATED int64 = 1492261242791293300