
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Get all href urls from an HTML string
Install get-hrefs using npm:
npm install --save get-hrefs
const getHrefs = require('get-hrefs');
getHrefs(`
<body>
<a href="http://example.com">Example</a>
</body>
`);
// ["http://example.com"]
getHrefs(`
<head>
<base href="http://example.com/path1/">
</head>
<body>
<a href="path2/index.html">Example</a>
</body>
`);
// ["http://example.com/path1/path2/index.html"]
$> get-hrefs --help
Get all href urls from an HTML string
Usage:
get-hrefs <html file>
cat <html file> | get-hrefs
Options:
-b, --base-url Set baseUrl
<all other flags are passed to normalize-url>
Examples:
curl -s example.com | get-hrefs
echo '<a href="http://www.example.com">Link</a>' | get-hrefs --strip-w-w-w
getHrefs(html, [options])| Name | Type | Description |
|---|---|---|
| html | String | The HTML string to extract hrefs from |
| options | Object | Optional options |
Returns: Array<String>, all unique and normalized hrefs resolved from any provided baseUrl and <base href="..."> in the HTML document.
Type: String
Default: ""
The baseUrl to use for relative hrefs. The module also takes <base ...> tags into account.
Type: Object
Default: {"http": true, "https": true}
Specifies which protocols to allow by setting their respective key (the protocol name without ":") in allowedProtocols to true (or to false to disable one of the defaults), e.g. allowedProtocols: {tel: true, http: false} will return only found URLs with the protocols tel: or https:.
<any>All other options are passed to normalize-url. See its options for alternatives.
MIT © Joakim Carlstein
FAQs
Get all href urls from an HTML string
We found that get-hrefs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.