about summary refs log tree commit diff
path: root/bskyembed/snippet
diff options
context:
space:
mode:
Diffstat (limited to 'bskyembed/snippet')
-rw-r--r--bskyembed/snippet/embed.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/bskyembed/snippet/embed.ts b/bskyembed/snippet/embed.ts
index f2b9b442e..380cda5fb 100644
--- a/bskyembed/snippet/embed.ts
+++ b/bskyembed/snippet/embed.ts
@@ -59,9 +59,19 @@ function scan(node = document) {
       continue
     }
 
+    const ref_url = location.origin + location.pathname
+
+    const searchParams = new URLSearchParams()
+    searchParams.set('id', id)
+    if (ref_url.startsWith('http')) {
+      searchParams.set('ref_url', encodeURIComponent(ref_url))
+    }
+
     const iframe = document.createElement('iframe')
     iframe.setAttribute('data-bluesky-id', id)
-    iframe.src = `${EMBED_URL}/embed/${aturi.slice('at://'.length)}?id=${id}`
+    iframe.src = `${EMBED_URL}/embed/${aturi.slice(
+      'at://'.length,
+    )}?${searchParams.toString()}`
     iframe.width = '100%'
     iframe.style.border = 'none'
     iframe.style.display = 'block'