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"
)
// LinkMetadata mirrors the TS shape in
// `js/desktop/src/lib/link-metadata.ts`. The Electron client does this fetch
// in its main process; the web client can't (browser CORS), so it calls this
// endpoint instead.
// LinkMetadata mirrors the TS shape in `js/desktop/src/lib/link-metadata.ts`.
// All clients (web and Electron) call this endpoint — the Electron main-process
// fetcher was retired so both clients share one parser and the server-side cache.
type LinkMetadata struct {
URL string `json:"url"`
Title *string `json:"title"`
@@ -33,8 +32,8 @@ const (
metadataUserAgent = "Mozilla/5.0 (compatible; llink/1.0)"
)
// In-process cache, unbounded but only successful results are stored. Mirrors
// the Electron-main implementation; URL space is bounded in practice.
// In-process cache, unbounded but only successful results are stored.
// URL space is bounded in practice.
var metadataCache sync.Map // map[string]LinkMetadata
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
}
// 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>`)
func parseTitle(html string) *string {