1
0
mirror of https://github.com/writeas/htmlhouse synced 2025-07-18 21:08:16 +00:00

Catch errors parsing PreviewsHost URI

This prevents the app crashing if a bad URI is given.
This commit is contained in:
Matt Baer 2018-03-12 11:10:55 -04:00
parent 597395f312
commit 702d5234c0

View File

@ -7,6 +7,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"os"
"regexp"
"strconv"
"strings"
@ -90,6 +91,10 @@ func addPublicAccess(app *app, houseID, html string) error {
data.Set("url", fmt.Sprintf("%s/%s.html", app.cfg.HostName, houseID))
u, err := url.ParseRequestURI(app.cfg.PreviewsHost)
if err != nil {
fmt.Fprintf(os.Stderr, "Error parsing request URI: %v\n", err)
return err
}
u.Path = "/"
urlStr := fmt.Sprintf("%v", u)