From b1058b9fcc988d5d717b44b4e7dd718c1351f946 Mon Sep 17 00:00:00 2001 From: TDaglis Date: Thu, 22 Oct 2015 06:47:15 +0000 Subject: [PATCH] Added lenient option to linkify --- addons/linkify/linkify.js | 45 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/addons/linkify/linkify.js b/addons/linkify/linkify.js index 543e5feb..61cadb99 100644 --- a/addons/linkify/linkify.js +++ b/addons/linkify/linkify.js @@ -7,14 +7,14 @@ } else { /* * Plain browser environment - */ + */ linkify(this.Xterm); } })(function (Xterm) { 'use strict'; /** - * This module provides methods for convertings valid URL substrings + * This module provides methods for convertings valid URL substrings * into HTML anchor elements (links), inside a terminal view. * * @module xterm/addons/linkify/linkify @@ -31,8 +31,11 @@ bodyClause = hostClause + pathClause, start = '(?:^|' + negatedDomainCharacterSet + ')(', end = ')($|' + negatedPathCharacterSet + ')', - urlClause = start + protocolClause + '?' + bodyClause + end, - urlRegex = new RegExp(urlClause); + lenientUrlClause = start + protocolClause + '?' + bodyClause + end, + strictUrlClause = start + protocolClause + bodyClause + end, + lenientUrlRegex = new RegExp(lenientUrlClause), + strictUrlRegex = new RegExp(strictUrlClause); + /** * Converts all valid URLs found in the given terminal line into @@ -46,7 +49,7 @@ * @emits linkify * @emits linkify:line */ - exports.linkifyTerminalLine = function (terminal, line) { + exports.linkifyTerminalLine = function (terminal, line, lenient) { if (typeof line == 'number') { line = terminal.rowContainer.children[line]; } else if (! (line instanceof HTMLDivElement)) { @@ -60,7 +63,8 @@ nodes = line.childNodes; for (var j=0; j