refactor: cleanup comments

This commit is contained in:
Arjun Patel
2026-05-26 14:12:12 -07:00
parent e38d34f5b5
commit 1e992abf41
+5 -9
View File
@@ -14,10 +14,9 @@ import (
"time" "time"
) )
// LinkMetadata mirrors the TS shape in // LinkMetadata mirrors the TS shape in `js/desktop/src/lib/link-metadata.ts`.
// `js/desktop/src/lib/link-metadata.ts`. The Electron client does this fetch // All clients (web and Electron) call this endpoint — the Electron main-process
// in its main process; the web client can't (browser CORS), so it calls this // fetcher was retired so both clients share one parser and the server-side cache.
// endpoint instead.
type LinkMetadata struct { type LinkMetadata struct {
URL string `json:"url"` URL string `json:"url"`
Title *string `json:"title"` Title *string `json:"title"`
@@ -33,8 +32,8 @@ const (
metadataUserAgent = "Mozilla/5.0 (compatible; llink/1.0)" metadataUserAgent = "Mozilla/5.0 (compatible; llink/1.0)"
) )
// In-process cache, unbounded but only successful results are stored. Mirrors // In-process cache, unbounded but only successful results are stored.
// the Electron-main implementation; URL space is bounded in practice. // URL space is bounded in practice.
var metadataCache sync.Map // map[string]LinkMetadata var metadataCache sync.Map // map[string]LinkMetadata
func (h *Handler) GetLinkMetadata(w http.ResponseWriter, r *http.Request) { func (h *Handler) GetLinkMetadata(w http.ResponseWriter, r *http.Request) {
@@ -139,9 +138,6 @@ func fetchLinkMetadata(ctx context.Context, target *url.URL) (*LinkMetadata, err
}, nil }, nil
} }
// Regex patterns mirror the JS impl in `js/desktop/src/main.ts` so both clients
// derive the same metadata until the JS path is retired.
var titleRe = regexp.MustCompile(`(?i)<title[^>]*>([^<]*)</title>`) var titleRe = regexp.MustCompile(`(?i)<title[^>]*>([^<]*)</title>`)
func parseTitle(html string) *string { func parseTitle(html string) *string {