Possibly fix #79

This commit is contained in:
Henrique Dias committed 2017-04-15 14:00:41 +01:00
1 parent e46a007c71
commit 056ea2b8bd
6 files changed
+18 -9

No files matched your search

+1 -1
View File
@@ -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)
+11 -2
View File
@@ -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(),
}