Skip to content

fix(iframe): extract src from pasted embed code - #384

Merged
hunghg255 merged 1 commit into
hunghg255:mainfrom
M4rdine:fix/iframe-embed-src
Oct 6, 2026
Merged

hunghg255 merged 1 commit into
hunghg255:mainfrom
M4rdine:fix/iframe-embed-src

Conversation

@M4rdine

@M4rdine M4rdine commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

When you paste the embed code from Google Maps ("Share > Embed a map > Copy HTML") into the iframe dialog, the whole <iframe ...> string ends up in src. The browser treats it as a relative path and the frame shows a 404 page. Same thing happens with HTML-escaped input (&lt;iframe src=&quot;...) or urls with &amp;.

getServiceSrc now reduces the input to the url before detecting the service:

  • decodes the common HTML entities
  • if the input contains an <iframe> tag, uses its src (double, single or no quotes)
  • trims whitespace

Since the YouTube/Google Maps/etc. detection runs after that, a pasted YouTube embed snippet still gets converted as before.

While testing I also hit two link formats that weren't recognized:

  • YouTube youtube.com/shorts/ID and youtube.com/live/ID (added to the existing regex)
  • Vimeo vimeo.com/ID and player.vimeo.com/video/ID (new vimeo service, resolves to player.vimeo.com/video/ID)

Both the toolbar dialog and the iframe bubble go through getServiceSrc, so they both get the fix. Content that was already saved with a broken src isn't migrated.

Tests

Added tests/iframe-utils.test.ts (node:test, same setup as the other tests):

pnpm exec esno --test tests/iframe-utils.test.ts

pnpm lint, pnpm fmt:check on the changed files, pnpm type-check, pnpm test:types and pnpm build:lib pass.

Pasting a full embed snippet (e.g. Google Maps "Copy HTML") stored the
whole <iframe> tag as the src, so the frame loaded a relative 404 page.
The input is now reduced to the src url and HTML entities are decoded.

Also resolve YouTube shorts/live links and Vimeo links to embed urls.
@vercel

vercel Bot commented Oct 5, 2026

Copy link
Copy Markdown

@M4rdine is attempting to deploy a commit to the Gia Hung's projects Team on Vercel.

A member of the Team first needs to authorize it.

@hunghg255
hunghg255 merged commit c3ce5d3 into hunghg255:main Oct 6, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants