mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-31 19:54:29 +01:00
fix nip-05 links again.
This commit is contained in:
@@ -42,6 +42,12 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// it may be a NIP-05
|
||||
if strings.Contains(code, ".") {
|
||||
renderProfile(w, r, code)
|
||||
return
|
||||
}
|
||||
|
||||
// otherwise error
|
||||
w.Header().Set("Cache-Control", "max-age=60")
|
||||
errorPage := &ErrorPage{
|
||||
@@ -54,7 +60,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// render npub and nprofile using a separate function
|
||||
if strings.HasPrefix(code, "npub") || strings.HasPrefix(code, "nprofile") {
|
||||
if prefix == "npub" || prefix == "nprofile" {
|
||||
// it's a profile
|
||||
renderProfile(w, r, code)
|
||||
return
|
||||
|
||||
@@ -24,21 +24,22 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
|
||||
}
|
||||
|
||||
data, err := grabData(r.Context(), code, isSitemap)
|
||||
|
||||
if err != nil {
|
||||
w.Header().Set("Cache-Control", "max-age=60")
|
||||
} else if len(data.renderableLastNotes) != 0 {
|
||||
w.Header().Set("Cache-Control", "max-age=3600")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errorPage := &ErrorPage{
|
||||
Errors: err.Error(),
|
||||
}
|
||||
errorPage.TemplateText()
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
ErrorTemplate.Render(w, errorPage)
|
||||
} else if isSitemap {
|
||||
return
|
||||
}
|
||||
|
||||
if len(data.renderableLastNotes) != 0 {
|
||||
w.Header().Set("Cache-Control", "max-age=3600")
|
||||
}
|
||||
|
||||
if isSitemap {
|
||||
w.Header().Add("content-type", "text/xml")
|
||||
w.Write([]byte(XML_HEADER))
|
||||
SitemapTemplate.Render(w, &SitemapPage{
|
||||
|
||||
Reference in New Issue
Block a user