From 99c492a9e28b5d7d3fab9492d878dc875b95610c Mon Sep 17 00:00:00 2001 From: Ilya Cohn Date: Tue, 22 Mar 2016 13:26:23 +0000 Subject: [PATCH 1/2] Improve link handling (mostly URLs) by recombining plain text fragments into one As each link type may preforme additional check. If the check fails, the fragment is counted as plain text. Recombining adjacent plain text fragments will inprouve link detection --- url2link.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/url2link.js b/url2link.js index 8314355..49b1056 100644 --- a/url2link.js +++ b/url2link.js @@ -96,7 +96,7 @@ _Url2link.prototype = { }] } ,"uname":{ - "regex": /@[-a-z0-9]{3,}/ + "regex": /@[A-Za-z0-9]{3,25}/ ,"newtab": true ,"flags":"i" ,"actions":[function(match, host){ @@ -107,7 +107,7 @@ _Url2link.prototype = { ,"link": function(input){ var that = this; var matches = new Array(); - var out = new Array({"type":"text", "prefix":"", "val":input, "start":0}); + var out = new Array({"type":"text", "val":input}); ["email","url","uname"].forEach(function(type){ var newOut = new Array(); @@ -116,7 +116,7 @@ _Url2link.prototype = { newOut = newOut.concat(digest(type, el.val, el.start)); else newOut = newOut.concat(el); }); - out = newOut; + out = fuseText(newOut); }); function digest(t, text, start){ @@ -146,6 +146,18 @@ _Url2link.prototype = { output.push(textobj(text.slice(prevIdx))); return output; } + function fuseText(inp){ + if(!inp.length)return inp; + var outIdx = 0; + var out = new Array(); + out.push(inp[0]); + for (var idx = 1; idx Date: Wed, 23 Mar 2016 21:53:03 +0000 Subject: [PATCH 2/2] Avoid changing URLs on domains other than FreeFeed forntends --- utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.js b/utils.js index bdcc115..0cc4d5b 100644 --- a/utils.js +++ b/utils.js @@ -433,7 +433,7 @@ _Utils.prototype = { }); } ,"setFrontUrl": function(url){ - return url.replace(/((beta|m)\.)?freefeed.net\/(?=.+)/, + return url.replace(/((https?:\/\/)|beta\.|m\.|^)freefeed.net\/(?=.+)/, gConfig.front.slice(8)); } };