Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Find URLs, email addresses, #hashtags and @mentions in plain-text strings, then convert them into HTML links.
The linkifyjs package is a robust tool for finding links in plain text and converting them into clickable HTML hyperlinks. It is useful for enhancing user-generated content where links are not automatically hyperlinked.
Link Detection
Detects URLs and email addresses in plain text and provides details about them. This feature is useful for applications that need to extract hyperlink information from text.
const linkify = require('linkifyjs');
const text = 'Visit http://example.com for more info.';
const html = linkify.find(text);
console.log(html);
Convert Text to HTML
Converts plain text containing URLs or email addresses into HTML with clickable links. This is particularly useful for rendering user-generated content safely in web applications.
const linkifyHtml = require('linkifyjs/html');
const text = 'See more at http://example.com.';
const linkedText = linkifyHtml(text);
console.log(linkedText);
Like linkifyjs, autolinker is also designed to automatically convert URLs, email addresses, and Twitter usernames into clickable links in text. It offers additional features like customizing how links are displayed, which might be advantageous depending on the use case.
Core linkify library.
Install from the command line with NPM
npm install linkifyjs
Import into your JavaScript with require
const linkify = require('linkifyjs');
or with ES modules
import * as linkify from 'linkifyjs';
v3.0.0
linkify-react
,linkify-jquery
and linkify-element
respectively:class="linkified"
from all discovered links. Opt back in by setting the className
option:
linkifyStr(str, { className: "linkified" });
target="_blank"
attribute for discovered URLs. Opt back in by setting the target
option:
linkifyHtml(str, {
target: (href, type) => type === "url" && "_blank",
});
<span>
tag wrapper in favour of tag-less React.Fragment
for React >=16. To opt back-in, set tagName='span'
:
<Linkify tagName="span">{content}</Linkify>
linkify-string
and linkify-html
instead of linkifyjs/string
and linkifyjs/html
. The embedded packages will be removed in v4.0linkify-plugin-[PLUGIN]
instead of linkifyjs/plugin/[PLUGIN]
. The embedded packages will be removed in v4.0Full Internationalized Domain (IDN) and Emoji domain support 🇺🇳🌍✈️🎉💃! Detect URLs, #hashtags and @mentions in any language
~10x faster startup; ~4x faster combined startup + first run
Custom protocols with linkify.registerCustomProtocol('protocol')
Modernized codebase and build system
Add new rel
option at top level as an alternate way of including it in attributes
New and improved plugin API
TypeScript definitions included in published packages
linkify.find()
output includes start and end indexes for where in the string a link was found
Plugins no longer need to be called on linkify after import
// Before
import * as linkify from "linkifyjs";
import hashtag from "linkifyjs/plugins/hashtag";
hashtag(linkify);
// After
import * as linkify from "linkifyjs";
import "linkifyjs/plugins/hashtag";
FAQs
Find URLs, email addresses, #hashtags and @mentions in plain-text strings, then convert them into HTML links.
The npm package linkifyjs receives a total of 800,390 weekly downloads. As such, linkifyjs popularity was classified as popular.
We found that linkifyjs demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.