New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@debank/parse-favicon

Package Overview
Dependencies
Maintainers
12
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@debank/parse-favicon

Parse HTML to get icon information

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
12
Created
Source

@debank/parse-favicon npm

NOTICE: This repo is forked from parse-favicon, can be ONLY delivered & used in @debank scope, all rights reserved by original author.

Parse HTML to get icon information.

Install

npm install --save @debank/parse-favicon
# or
yarn add @debank/parse-favicon

Usage

import { parseFavicon } from '@debank/parse-favicon'

const pageUrl = 'https://github.com'

parseFavicon(pageUrl, textFetcher, bufferFetcher).subscribe(icon => console.log(icon))

async function textFetcher(url) {
  return await fetch(resolveUrl(url, pageUrl)).then(res => res.text())
}

async function bufferFetcher(url) {
  return await fetch(resolveUrl(url, pageUrl)).then(res => res.arrayBuffer())
}

function resolveUrl(url, base) {
  return new URL(url, base).href
}

API

parseFavicon

parseFavicon(
  url: string
, textFetcher: TextFetcher
, bufferFetcher?: BufferFetcher
): Observable<Icon>

type TextFetcher = (url: string) => PromiseLike<string>
type BufferFetcher = (url: string) => PromiseLike<ArrayBuffer>

interface Icon {
  url: string
  reference: string
  type: null | string
  size: null | 'any' | Size | Size[]
}

interface Size {
  width: number
  height: number
}

parseFavicon accepts textFetcher and bufferFetcher for further fetching requests when parsing icons, bufferFetcher is optional. If you need actual icon sizes and type, should provide bufferFetcher.

References related to textFetcher:

  • <meta name="msapplication-config" content="path/to/ieconfig.xml">
  • <link rel="manifest" href="path/to/manifest.webmanifest">

References related to bufferFetcher:

  • /favicon.ico
  • /apple-touch-icon-57x57-precomposed.png
  • /apple-touch-icon-57x57.png
  • /apple-touch-icon-72x72-precomposed.png
  • /apple-touch-icon-72x72.png
  • /apple-touch-icon-114x114-precomposed.png
  • /apple-touch-icon-114x114.png
  • /apple-touch-icon-120x120-precomposed.png
  • /apple-touch-icon-120x120.png
  • /apple-touch-icon-144x144-precomposed.png
  • /apple-touch-icon-144x144.png
  • /apple-touch-icon-152x152-precomposed.png
  • /apple-touch-icon-152x152.png
  • /apple-touch-icon-180x180-precomposed.png
  • /apple-touch-icon-180x180.png
  • /apple-touch-icon-precomposed.png
  • /apple-touch-icon.png

Support references

  • <link rel="icon" href="path/to/icon.png">
  • <link rel="shortcut icon" href="path/to/icon.ico">
  • <link rel="apple-touch-icon" href="path/to/icon.png">
  • <link rel="apple-touch-icon-precomposed" href="path/to/icon.png">
  • <link rel="manifest" href="path/to/manifest.webmanifest">
  • <link rel="fluid-icon" href="path/to/icon.png">
  • <link rel="mask-icon" href="path/to/icon.svg">
  • <meta name="msapplication-TileImage" content="path/to/icon.png">
  • <meta name="msapplication-config" content="path/to/ieconfig.xml">
  • <meta name="msapplication-square70x70logo" content="path/to/icon.png">
  • <meta name="msapplication-square150x150logo" content="path/to/icon.png">
  • <meta name="msapplication-square310x310logo" content="path/to/icon.png">
  • <meta name="msapplication-wide310x150logo" content="path/to/icon.png">
  • /favicon.ico
  • /apple-touch-icon-57x57-precomposed.png
  • /apple-touch-icon-57x57.png
  • /apple-touch-icon-72x72-precomposed.png
  • /apple-touch-icon-72x72.png
  • /apple-touch-icon-114x114-precomposed.png
  • /apple-touch-icon-114x114.png
  • /apple-touch-icon-120x120-precomposed.png
  • /apple-touch-icon-120x120.png
  • /apple-touch-icon-144x144-precomposed.png
  • /apple-touch-icon-144x144.png
  • /apple-touch-icon-152x152-precomposed.png
  • /apple-touch-icon-152x152.png
  • /apple-touch-icon-180x180-precomposed.png
  • /apple-touch-icon-180x180.png
  • /apple-touch-icon-precomposed.png
  • /apple-touch-icon.png

Keywords

FAQs

Package last updated on 21 Sep 2022

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