Project

bx-unfurl

Link previews for BoxLang. unfurl() fetches a pasted link without letting it reach your internal network, and returns its Open Graph, Twitter card and plain-HTML metadata as one struct. GitHub, YouTube, npm, Mastodon, Bluesky and other sites whose API knows more than their pages say are read from the API instead.

v0.1.0 ·

One card for any page

Title, description, images, video, favicon, author and date, from Open Graph, Twitter tags or plain HTML, whichever the page has. Every address comes back absolute.

Nine sites read from their APIs

GitHub repositories, issues and pull requests, YouTube, Vimeo, npm, ForgeBox, Mastodon, Bluesky, Reddit and Wikipedia, each with its own details. Pages that name an oEmbed endpoint get its author, thumbnail and embed.

Refuses internal addresses

Every redirect hop is checked against loopback, private, link-local and the other internal ranges, so a pasted link can't reach localhost or cloud metadata. Time, size and redirect limits on every fetch.

Bring your own HTML

unfurlHtml() reads the same card from a page you already have, as a string or bytes. No database cache and no image copying: cache cards and proxy images the way your app already does.

bashinstall-bx-module bx-unfurl
javascriptcard = unfurl( "https://github.com/robertz/bx-unfurl" )

card.title        // og:title, twitter:title, or <title>
card.description
card.image        // the first image's address, or ""
card.source       // "page", "image", or a provider such as "github"
card.details      // the provider's own fields: stars, forks, language...

Requires BoxLang 1.19.0 or later. jsoup is bundled in the module.

Install, settings and error handling →