JSPM

extract-hrefs

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 62
  • Score
    100M100P100Q78823F
  • License MIT

This library is used to extract hrefs from a given HTML string.

Package Exports

  • extract-hrefs
  • extract-hrefs/dist/index.js
  • extract-hrefs/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (extract-hrefs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Extract Hrefs

This library provides a simple way to extract href attributes from HTML content and normalize the URLs.

Installation

npm install extract-hrefs

Usage

import { extractHrefs } from 'extract-hrefs';

const html = `
    <!DOCTYPE html>
    <html lang="en">
    <head>
        this is test
    </head>
    <body>
        <p>
            <a href="https://example.com">Example</a>
            <a href="https://example.com/test">Example Test</a>
        </p>
    </body>
`;

const links = extractHrefs(html);
console.log(links);

Output

[ 'https://example.com/', 'https://example.com/test' ]

If you like my work, please consider giving it a star on GitHub or Sponsor my work by following sponsoring me link.