small bug fixes

This commit is contained in:
Henrique Dias
2016-08-22 12:24:26 +01:00
parent 1df11145a8
commit de984c3037
3 changed files with 29 additions and 6 deletions

View File

@@ -70,12 +70,20 @@ func Parse(c *caddy.Controller) ([]Config, error) {
Regexp: regexp.MustCompile("\\/\\..+"),
}}
// Get the baseURL
args := c.RemainingArgs()
if len(args) > 0 {
cfg.BaseURL = args[0]
}
// Set the first user, the global user
user = cfg.User
for c.NextBlock() {
switch c.Val() {
case "on":
// NOTE: DEPRECATED
if !c.NextArg() {
return configs, c.ArgErr()
}
@@ -212,6 +220,10 @@ func Parse(c *caddy.Controller) ([]Config, error) {
cfg.BaseURL = strings.TrimSuffix(cfg.BaseURL, "/")
cfg.BaseURL = "/" + cfg.BaseURL
if cfg.BaseURL == "/" {
cfg.BaseURL = ""
}
caddyConf := httpserver.GetConfig(c)
cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)