···
// mapOEmbedToResult converts oEmbed response to UnfurlResult
func mapOEmbedToResult(oembed *oEmbedResponse, originalURL string) *UnfurlResult {
Description: oembed.Description,
-
ThumbnailURL: oembed.ThumbnailURL,
Provider: strings.ToLower(oembed.ProviderName),
Domain: extractDomain(originalURL),
···
Description: og.Description,
-
ThumbnailURL: og.Image,
Domain: extractDomain(urlStr),
···
+
// normalizeURL converts protocol-relative URLs to HTTPS
+
// "//example.com/image.jpg" -> "https://example.com/image.jpg"
+
// "https://example.com/image.jpg" -> "https://example.com/image.jpg" (unchanged)
+
func normalizeURL(urlStr string) string {
+
if strings.HasPrefix(urlStr, "//") {
+
return "https:" + urlStr
// mapOEmbedToResult converts oEmbed response to UnfurlResult
func mapOEmbedToResult(oembed *oEmbedResponse, originalURL string) *UnfurlResult {
Description: oembed.Description,
+
ThumbnailURL: normalizeURL(oembed.ThumbnailURL),
Provider: strings.ToLower(oembed.ProviderName),
Domain: extractDomain(originalURL),
···
Description: og.Description,
+
ThumbnailURL: normalizeURL(og.Image),
Domain: extractDomain(urlStr),