fix add an extra flag for the URL port

This commit is contained in:
Tom Andrade 2022-05-18 15:11:07 +02:00
parent d8e77cc756
commit f88b908ade
Signed by: wolvie
GPG Key ID: 31AAB07872E82669

View File

@ -71,8 +71,9 @@ func main() {
version = flag.Bool("v", false, "prints current version")
listenAddr string
)
flag.StringVar(&shortie.DumpFile, "dumpfile", "Path to the file to dump the kv db", "urls.json")
flag.StringVar(&shortie.DumpFile, "dumpFile", "Path to the file to dump the kv db", "urls.json")
flag.IntVar(&shortie.URLSize, "size", 10, "Define the size of the shortened String")
flag.IntVar(&shortie.Port, "urlPort", 443, "Port to use for building URLs")
flag.Parse()
@ -81,10 +82,14 @@ func main() {
os.Exit(0)
}
if shortie.Port > 65535 || shortie.Port < 1 {
log.Fatalln("Invalid port number")
}
if *port > 65535 || *port < 1 {
log.Fatalln("Invalid port number")
}
shortie.Port = *port
if *path != "" && !strings.HasSuffix(*path, "/") {
*path = *path + "/"
}