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:
parent
597395f312
commit
702d5234c0
@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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))
|
data.Set("url", fmt.Sprintf("%s/%s.html", app.cfg.HostName, houseID))
|
||||||
|
|
||||||
u, err := url.ParseRequestURI(app.cfg.PreviewsHost)
|
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 = "/"
|
u.Path = "/"
|
||||||
urlStr := fmt.Sprintf("%v", u)
|
urlStr := fmt.Sprintf("%v", u)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user