Possibly fix #79
Former-commit-id: 448fc22e05a58cf627cf1f553170a010899b7609 [formerly d4a2c9b18746d2d14ac203c7d71f60251a2d9d18] [formerly 7632da5ecace133715b76d9506cc1b75c89bd659 [formerly 056ea2b8bd3b073887f0fb173b78faa4bce48087]] Former-commit-id: 08e76feb0c947f494ce8c9aaaa6f8b8026b8816c [formerly c4dd6fb80ed0ed9d7890e51d1983ca03adf6b7a2] Former-commit-id: 5d04fdd2c6ed7cf4468cd82909a6605ecbe853ba
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user