Socket
Socket
Sign inDemoInstall

linkifyjs

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkifyjs - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

18

lib/linkify-element.js

@@ -16,3 +16,3 @@ /**

Given a parent element and child node that the parent contains, replaces
that child with the given aary of new children
that child with the given array of new children
*/

@@ -31,5 +31,6 @@ function replaceChildWithChildren(parent, oldChild, newChildren) {

(a) Plain Text nodes (node type 3)
(b) Anchor tag nodes (usually, unless tag name is overriden in the options)
(b) Anchor tag nodes (usually, unless tag name is overridden in the options)
Takes the same options as linkifyElement and an optional doc element (this should be passed in by linkifyElement)
Takes the same options as linkifyElement and an optional doc element
(this should be passed in by linkifyElement)
*/

@@ -104,4 +105,3 @@ function tokensToNodes(tokens, opts, doc) {

var children = [],
childElement = element.firstChild;
var childElement = element.firstChild;

@@ -112,3 +112,3 @@ while (childElement) {

case HTML_NODE:
children.push(linkifyElementHelper(childElement, opts, doc));
linkifyElementHelper(childElement, opts, doc);
break;

@@ -128,5 +128,2 @@ case TXT_NODE:

break;
default:
children.push(childElement);break;
}

@@ -155,4 +152,3 @@

// Maintain reference to the recursive helper to save some option-normalization
// cycles
// Maintain reference to the recursive helper to cache option-normalization
linkifyElement.helper = linkifyElementHelper;

@@ -159,0 +155,0 @@ linkifyElement.normalize = _linkify.options.normalize;

@@ -32,2 +32,3 @@ /**

TT_DOT = _tokens.text.DOT,
TT_PUNCTUATION = _tokens.text.PUNCTUATION,
TT_LOCALHOST = _tokens.text.LOCALHOST,

@@ -117,5 +118,6 @@ TT_NL = _tokens.text.NL,

S_START.on(TT_LOCALHOST, S_TLD);
S_START.on(TT_NUM, S_LOCALPART);
S_START.on(TT_NUM, S_DOMAIN);
S_PROTOCOL_SLASH_SLASH.on(TT_TLD, S_PSS_DOMAIN);
S_PROTOCOL_SLASH_SLASH.on(TT_DOMAIN, S_PSS_DOMAIN);
S_PROTOCOL_SLASH_SLASH.on(TT_NUM, S_PSS_DOMAIN);
S_PROTOCOL_SLASH_SLASH.on(TT_LOCALHOST, S_PSS_TLD);

@@ -134,8 +136,11 @@

S_DOMAIN_DOT.on(TT_DOMAIN, S_DOMAIN);
S_DOMAIN_DOT.on(TT_NUM, S_DOMAIN);
S_DOMAIN_DOT.on(TT_LOCALHOST, S_DOMAIN);
S_PSS_DOMAIN_DOT.on(TT_TLD, S_PSS_TLD);
S_PSS_DOMAIN_DOT.on(TT_DOMAIN, S_PSS_DOMAIN);
S_PSS_DOMAIN_DOT.on(TT_NUM, S_PSS_DOMAIN);
S_PSS_DOMAIN_DOT.on(TT_LOCALHOST, S_PSS_DOMAIN);
S_EMAIL_DOMAIN_DOT.on(TT_TLD, S_EMAIL);
S_EMAIL_DOMAIN_DOT.on(TT_DOMAIN, S_EMAIL_DOMAIN);
S_EMAIL_DOMAIN_DOT.on(TT_NUM, S_EMAIL_DOMAIN);
S_EMAIL_DOMAIN_DOT.on(TT_LOCALHOST, S_EMAIL_DOMAIN);

@@ -163,3 +168,3 @@

// Types of characters the URL can definitely end in
var qsAccepting = [TT_DOMAIN, TT_AT, TT_LOCALHOST, TT_NUM, TT_PLUS, TT_POUND, TT_PROTOCOL, TT_SLASH, TT_TLD];
var qsAccepting = [TT_DOMAIN, TT_AT, TT_LOCALHOST, TT_NUM, TT_PLUS, TT_POUND, TT_PROTOCOL, TT_SLASH, TT_TLD, TT_SYM];

@@ -169,3 +174,3 @@ // Types of tokens that can follow a URL and be part of the query string

// Characters that cannot appear in the URL at all should be excluded
var qsNonAccepting = [TT_COLON, TT_DOT, TT_QUERY, TT_SYM];
var qsNonAccepting = [TT_COLON, TT_DOT, TT_QUERY, TT_PUNCTUATION];

@@ -184,3 +189,3 @@ // Account for the query string

// Tokens allowed in the localpart of the email
var localpartAccepting = [TT_DOMAIN, TT_COLON, TT_NUM, TT_PLUS, TT_POUND, TT_QUERY, TT_SYM, TT_TLD];
var localpartAccepting = [TT_DOMAIN, TT_NUM, TT_PLUS, TT_POUND, TT_QUERY, TT_SYM, TT_TLD];

@@ -194,8 +199,2 @@ // Some of the tokens in `localpartAccepting` are already accounted for here and

S_TLD.on(TT_AT, S_LOCALPART_AT);
S_TLD_COLON.on(localpartAccepting, S_LOCALPART);
S_TLD_COLON.on(TT_DOT, S_LOCALPART);
S_TLD_COLON.on(TT_AT, S_LOCALPART_AT);
S_TLD_PORT.on(localpartAccepting, S_LOCALPART);
S_TLD_PORT.on(TT_DOT, S_LOCALPART_DOT);
S_TLD_PORT.on(TT_AT, S_LOCALPART_AT);

@@ -202,0 +201,0 @@ // Okay we're on a localpart. Now what?

@@ -55,2 +55,3 @@ /**

S_START.on(COLON, makeState(_tokens.text.COLON));
S_START.on(/[,;!]/, makeState(_tokens.text.PUNCTUATION));

@@ -57,0 +58,0 @@ // Whitespace jumps

@@ -120,2 +120,24 @@ /******************************************************************************

/**
A character class that can surround the URL, but which the URL cannot begin
or end with. Does not include certain English punctuation like parentheses.
@class PUNCTUATION
@extends TextToken
*/
var PUNCTUATION = (function (_TextToken5) {
function PUNCTUATION() {
_classCallCheck(this, PUNCTUATION);
if (_TextToken5 != null) {
_TextToken5.apply(this, arguments);
}
}
_inherits(PUNCTUATION, _TextToken5);
return PUNCTUATION;
})(TextToken);
/**
The word localhost (by itself)

@@ -126,12 +148,12 @@ @class LOCALHOST

var LOCALHOST = (function (_TextToken5) {
var LOCALHOST = (function (_TextToken6) {
function LOCALHOST() {
_classCallCheck(this, LOCALHOST);
if (_TextToken5 != null) {
_TextToken5.apply(this, arguments);
if (_TextToken6 != null) {
_TextToken6.apply(this, arguments);
}
}
_inherits(LOCALHOST, _TextToken5);
_inherits(LOCALHOST, _TextToken6);

@@ -147,10 +169,10 @@ return LOCALHOST;

var TNL = (function (_TextToken6) {
var TNL = (function (_TextToken7) {
function TNL() {
_classCallCheck(this, TNL);
_TextToken6.call(this, '\n');
_TextToken7.call(this, '\n');
}
_inherits(TNL, _TextToken6);
_inherits(TNL, _TextToken7);

@@ -165,12 +187,12 @@ return TNL;

var NUM = (function (_TextToken7) {
var NUM = (function (_TextToken8) {
function NUM() {
_classCallCheck(this, NUM);
if (_TextToken7 != null) {
_TextToken7.apply(this, arguments);
if (_TextToken8 != null) {
_TextToken8.apply(this, arguments);
}
}
_inherits(NUM, _TextToken7);
_inherits(NUM, _TextToken8);

@@ -185,10 +207,10 @@ return NUM;

var PLUS = (function (_TextToken8) {
var PLUS = (function (_TextToken9) {
function PLUS() {
_classCallCheck(this, PLUS);
_TextToken8.call(this, '+');
_TextToken9.call(this, '+');
}
_inherits(PLUS, _TextToken8);
_inherits(PLUS, _TextToken9);

@@ -203,10 +225,10 @@ return PLUS;

var POUND = (function (_TextToken9) {
var POUND = (function (_TextToken10) {
function POUND() {
_classCallCheck(this, POUND);
_TextToken9.call(this, '#');
_TextToken10.call(this, '#');
}
_inherits(POUND, _TextToken9);
_inherits(POUND, _TextToken10);

@@ -229,12 +251,12 @@ return POUND;

var PROTOCOL = (function (_TextToken10) {
var PROTOCOL = (function (_TextToken11) {
function PROTOCOL() {
_classCallCheck(this, PROTOCOL);
if (_TextToken10 != null) {
_TextToken10.apply(this, arguments);
if (_TextToken11 != null) {
_TextToken11.apply(this, arguments);
}
}
_inherits(PROTOCOL, _TextToken10);
_inherits(PROTOCOL, _TextToken11);

@@ -249,10 +271,10 @@ return PROTOCOL;

var QUERY = (function (_TextToken11) {
var QUERY = (function (_TextToken12) {
function QUERY() {
_classCallCheck(this, QUERY);
_TextToken11.call(this, '?');
_TextToken12.call(this, '?');
}
_inherits(QUERY, _TextToken11);
_inherits(QUERY, _TextToken12);

@@ -267,10 +289,10 @@ return QUERY;

var SLASH = (function (_TextToken12) {
var SLASH = (function (_TextToken13) {
function SLASH() {
_classCallCheck(this, SLASH);
_TextToken12.call(this, '/');
_TextToken13.call(this, '/');
}
_inherits(SLASH, _TextToken12);
_inherits(SLASH, _TextToken13);

@@ -286,12 +308,12 @@ return SLASH;

var SYM = (function (_TextToken13) {
var SYM = (function (_TextToken14) {
function SYM() {
_classCallCheck(this, SYM);
if (_TextToken13 != null) {
_TextToken13.apply(this, arguments);
if (_TextToken14 != null) {
_TextToken14.apply(this, arguments);
}
}
_inherits(SYM, _TextToken13);
_inherits(SYM, _TextToken14);

@@ -306,12 +328,12 @@ return SYM;

var TLD = (function (_TextToken14) {
var TLD = (function (_TextToken15) {
function TLD() {
_classCallCheck(this, TLD);
if (_TextToken14 != null) {
_TextToken14.apply(this, arguments);
if (_TextToken15 != null) {
_TextToken15.apply(this, arguments);
}
}
_inherits(TLD, _TextToken14);
_inherits(TLD, _TextToken15);

@@ -328,12 +350,12 @@ return TLD;

var WS = (function (_TextToken15) {
var WS = (function (_TextToken16) {
function WS() {
_classCallCheck(this, WS);
if (_TextToken15 != null) {
_TextToken15.apply(this, arguments);
if (_TextToken16 != null) {
_TextToken16.apply(this, arguments);
}
}
_inherits(WS, _TextToken15);
_inherits(WS, _TextToken16);

@@ -349,2 +371,3 @@ return WS;

DOT: DOT,
PUNCTUATION: PUNCTUATION,
LOCALHOST: LOCALHOST,

@@ -351,0 +374,0 @@ NL: TNL,

{
"name": "linkifyjs",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "Intelligent link recognition, made easy",

@@ -5,0 +5,0 @@ "repository": {

@@ -21,2 +21,3 @@ # Linkify

- [Browser](#browser)
- [Downloads](#downloads)
- [API Documentation](#api-documentation)

@@ -43,3 +44,3 @@ - [Caveats](#caveats)

[Download](#downloads) the latest below or install via [NPM](https://www.npmjs.com/)
Download the [latest release](https://github.com/SoapBox/linkifyjs/releases), or install via [NPM](https://www.npmjs.com/)

@@ -171,2 +172,4 @@ ```

Download the [**latest release**](https://github.com/SoapBox/linkifyjs/releases)
**[linkify](http://soapbox.github.io/linkifyjs/docs/linkify.html)** _(required)_<br> [`.min.js`](https://github.com/nfrasser/linkify-shim/raw/master/linkify.min.js) · [`.js`](https://github.com/nfrasser/linkify-shim/raw/master/linkify.js) · [`.amd.min.js`](https://github.com/nfrasser/linkify-shim/raw/master/linkify.amd.min.js) · [`.amd.js`](https://github.com/nfrasser/linkify-shim/raw/master/linkify.amd.js)

@@ -173,0 +176,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc