Socket
Socket
Sign inDemoInstall

@joegesualdo/get-meta-information-from-html

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @joegesualdo/get-meta-information-from-html

Get <meta> tags information from HTML.


Version published
Weekly downloads
10
increased by66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@joegesualdo/get-meta-information-from-html Build Status

Get <meta> tags information from HTML.

Install

$ npm install --save @joegesualdo/get-meta-information-from-html 

Usage

import getMetaInformationFromHTML from '@joegesualdo/get-meta-information-from-html'

let html = `
  <head>
    <meta itemprop="description" content="This is a description">
    <meta name="title" content="This is a Title">
  </head>
`

getMetaInformationFromHTML(html)
.then(result => {
  console.log(result)
  //=>[
  //    {
  //      typeKey: 'itemprop',
  //      typeValue: 'description',
  //      value: 'This is a description' 
  //    },
  //    {
  //      typeKey: 'name',
  //      typeValue: 'Title',
  //      value: 'This is a title'
  //    }
  // ]
})

NOTE: Only looks for tags in the child nodes of the html provided. (Ie. <head><meta><head>)

Test

$ npm test

API

getMetaInformationFromHTML(html)

Get all the information from tags within the html provided

NameTypeDescription
htmlStringThe HTML you want to evaluate the tags from

Returns: Object, containing these keys: typeKey, typeValue, and value

import getMetaInformationFromHTML from '@joegesualdo/get-meta-information-from-html';

let html = `
  <head>
    <meta itemprop="description" content="This is a description">
    <meta name="title" content="This is a Title">
  </head>
`
getMetaInformationFromHTML(html)
.then(result => {
  console.log(result)
  //=>[
  //    {
  //      typeKey: 'itemprop',
  //      typeValue: 'description',
  //      value: 'This is a description' 
  //    },
  //    {
  //      typeKey: 'name',
  //      typeValue: 'Title',
  //      value: 'This is a title'
  //    }
  // ]
})

Build

$ npm run build

License

MIT © Joe Gesualdo

Keywords

FAQs

Last updated on 26 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc