Skip to content

Commit

Permalink
fix: make title access safer
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgtaylor committed Apr 1, 2024
1 parent 2b1e0b4 commit d9bbfb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,17 @@ func NewAPI(config Config, a Adapter) API {
openAPIPath = path.Join(prefix, openAPIPath)
}
ctx.SetHeader("Content-Type", "text/html")
title := "Elements in HTML"
if config.Info != nil && config.Info.Title != "" {
title = config.Info.Title + " Reference"
}
ctx.BodyWriter().Write([]byte(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>` + config.Info.Title + ` reference</title>
<title>` + title + ` reference</title>
<!-- Embed elements Elements via Web Component -->
<link href="https://unpkg.com/@stoplight/[email protected]/styles.min.css" rel="stylesheet" />
<script src="https://unpkg.com/@stoplight/[email protected]/web-components.min.js"
Expand Down

0 comments on commit d9bbfb3

Please sign in to comment.