chore: add location header

This commit is contained in:
johnnyjoy committed 2024-08-18 10:20:50 +08:00
1 parent 80548aaf2c
commit a3943f5b2d
3 files changed
+42 -1

No files matched your search

+5 -1
View File
@@ -92,9 +92,13 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
}
metric.Enqueue("shortcut view")
// Only set the `Location` header if the link is a valid URI.
if util.ValidateURI(shortcut.Link) {
c.Response().Header().Set("Location", shortcut.Link)
}
// Inject shortcut metadata into `index.html`.
indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateShortcutMetadata(shortcut).String())
return c.HTML(http.StatusOK, indexHTML)
return c.HTML(http.StatusSeeOther, indexHTML)
})
e.GET("/c/:collectionName", func(c echo.Context) error {