Skip to content

Commit

Permalink
fixed url escaping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
neel-bp committed Apr 6, 2023
1 parent faa5b0b commit d9b9e54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions httpinterface/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ var upgrader = websocket.Upgrader{

type StatusResponse struct {
core.JobState
ProjectName string `json:"projectName"`
DateTimeString string `json:"dateTimeString"`
Coverage float64 `json:"coverage"`
WebSocketRoute string `json:"websocketRoute"`
ProjectName string `json:"projectName"`
DateTimeString string `json:"dateTimeString"`
Coverage float64 `json:"coverage"`
WebSocketRoute template.URL `json:"websocketRoute"`
}

type WebsocketResponse struct {
Expand Down Expand Up @@ -194,7 +194,7 @@ func BuildStatus(w http.ResponseWriter, r *http.Request) {
ProjectName: projectID,
DateTimeString: result.LastBuildStart.Format(time.RFC3339),
Coverage: coverage,
WebSocketRoute: fmt.Sprintf(`ws://%s/%s/livestatus`, r.Host, projectID),
WebSocketRoute: template.URL(fmt.Sprintf("ws://%s/%s/livestatus", r.Host, projectID)),
}

tmpl := template.Must(template.ParseFiles("statuspage.html"))
Expand Down
2 changes: 1 addition & 1 deletion statuspage.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h3 class="subtitle is-5" id="lastBuildStart">{{.DateTimeString}}</h3>

lastBuildStart.innerHTML = time;

var socket = new WebSocket("{{.WebSocketRoute}}")
var socket = new WebSocket({{.WebSocketRoute}});

socket.onmessage = function (message) {
if (message.data != null) {
Expand Down

0 comments on commit d9b9e54

Please sign in to comment.