Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudflare-workers-unfurl

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudflare-workers-unfurl

Unfurl urls in cloudflare workers using HTMLRewriter

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by19.31%
Maintainers
0
Weekly downloads
 
Created
Source

cloudflare-workers-unfurl

A tiny utility to get basic information about a URL on Cloudflare Workers using the built-in HTMLRewriter API.

Usage

npm install cloudflare-workers-unfurl

There are two exports: unfurl and handleUnfurlRequest.

unfurl is the main function that does the work. It takes a URL and returns a promise that resolves to an object with the following properties:

  • title: The title of the page
  • description: The description of the page
  • image: The URL of the social image
  • favicon: The URL of the favicon
import { unfurl } from "cloudflare-workers-unfurl";

const result = await unfurl("https://example.com");

result.title; // 'Example Domain'

handleUnfurlRequest is a function that takes a Request object and returns a promise that resolves to a Response object. It uses unfurl to get the information about the URL in the url query parameter of the request and returns it as JSON.

import { AutoRouter } from "itty-router";
import { handleUnfurlRequest } from "cloudflare-workers-unfurl";

const router = AutoRouter();

router.get("/unfurl", handleUnfurlRequest);

export default router;

License

MIT

Keywords

FAQs

Package last updated on 23 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc