fix: Hide paste button when not connected via HTTPS

This commit is contained in:
Evan Fiordeliso 2023-08-16 11:33:15 -04:00
parent ffb35c3220
commit 9c98c333ad
2 changed files with 5 additions and 0 deletions

View File

@ -31,6 +31,7 @@ func (c *HomeController) Router(r chi.Router) {
func (c *HomeController) Index(w http.ResponseWriter, r *http.Request) {
hx := htmx.New(w, r)
isSecure := r.URL.Scheme == "https"
if hx.IsHtmxRequest() {
hx.PushUrl("/")
@ -40,6 +41,7 @@ func (c *HomeController) Index(w http.ResponseWriter, r *http.Request) {
"Version": version.Version,
"Build": version.Build,
"BinaryVersion": c.ytdl.Version(),
"IsSecure": isSecure,
})
} else {
app.Views.Render(w, "index", view.Data{
@ -47,6 +49,7 @@ func (c *HomeController) Index(w http.ResponseWriter, r *http.Request) {
"Version": version.Version,
"Build": version.Build,
"BinaryVersion": c.ytdl.Version(),
"IsSecure": isSecure,
}, "layouts/main")
}
}

View File

@ -27,6 +27,7 @@
required
placeholder="Enter url here then click download"
/>
{{if .IsSecure}}
<button
id="paste-button"
class="btn btn-outline-secondary"
@ -48,6 +49,7 @@
/>
</svg>
</button>
{{end}}
</div>
</div>
<div class="d-grid">