Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Convert all links inside a string to HTML anchor tags. It supports.
rel="noreferrer noopener"
as a security measure.www
.The code is hand-written in ES5 and is supposed to work with all major browsers. It makes use of var
over let or const
and for
over forEach
.
But you will need a commonjs module loader to make use of it.
npm i --save anchorify
const anchorify = require('anchorify')
assert.equal(
anchorify('Visit google.com'),
'Visit <a href="http://google.com"> google.com </a>'
)
// Set custom target
assert.equal(
anchorify('Visit google.com', { target: '_blank' }),
'Visit <a href="http://google.com" target="_blank" ref="noreferrer noopener"> google.com </a>'
)
// Do not touch existing anchor tags
assert.equal(
anchorify('Visit <a href="http://google.com"> google.com </a>', { target: '_blank' }),
'Visit <a href="http://google.com"> google.com </a>'
)
// Detect email
assert.equal(
anchorify('You can reach me at foo@bar.com'),
'You can reach me at <a href="mailto:foo@bar.com"> foo@bar.com </a>'
)
// Let browser decide the protocol
assert.equal(
anchorify('Open //google.com'),
'Open <a href="//google.com"> google.com </a>'
)
FAQs
Convert urls to anchor tags inside a string
The npm package anchorify receives a total of 1,119 weekly downloads. As such, anchorify popularity was classified as popular.
We found that anchorify 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.