Skip to content

Commit ed50ffa

Browse files
committed
fix(config): validate web_host url
1 parent 7a06f06 commit ed50ffa

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

util/config.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,19 @@ func ConfigInit(configPath string, noConfigFile bool) (usedConfigPath *string) {
270270
}
271271

272272
Cookie = securecookie.New(hash, encryption)
273-
WebHostURL, _ = url.Parse(Config.WebHost)
274-
if len(WebHostURL.String()) == 0 {
273+
274+
if Config.WebHost != "" {
275+
var err error
276+
WebHostURL, err = url.Parse(Config.WebHost)
277+
278+
if err != nil {
279+
panic(err)
280+
}
281+
282+
if len(WebHostURL.String()) == 0 {
283+
WebHostURL = nil
284+
}
285+
} else {
275286
WebHostURL = nil
276287
}
277288

0 commit comments

Comments
 (0)