diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-04-01 15:05:54 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-04-01 15:05:54 -0400 |
commit | a427d61b33fa0e3926c61bab456feb907a89af59 (patch) | |
tree | b6b5901fa739971020d4662d7de27d8b9c78de5f /webapp/utils/utils.jsx | |
parent | d9d6a0c7837d585297047e2a606ef20c86bfdfc2 (diff) | |
parent | 9ec459526a2bf4d119ab779473c9606c524b6131 (diff) | |
download | chat-a427d61b33fa0e3926c61bab456feb907a89af59.tar.gz chat-a427d61b33fa0e3926c61bab456feb907a89af59.tar.bz2 chat-a427d61b33fa0e3926c61bab456feb907a89af59.zip |
Merge pull request #2602 from ZBoxApp/autolinker
Replace Autolinker in extractLinks with a pattern
Diffstat (limited to 'webapp/utils/utils.jsx')
-rw-r--r-- | webapp/utils/utils.jsx | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index b248368fc..dc9291ab7 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -14,7 +14,6 @@ var ActionTypes = Constants.ActionTypes; import * as Client from './client.jsx'; import * as AsyncClient from './async_client.jsx'; import * as client from './client.jsx'; -import Autolinker from 'autolinker'; import React from 'react'; import {browserHistory} from 'react-router'; @@ -314,14 +313,8 @@ export function getTimestamp() { } // extracts links not styled by Markdown -export function extractLinks(text) { - text; // eslint-disable-line no-unused-expressions - Autolinker; // eslint-disable-line no-unused-expressions - - // skip this operation because autolinker is having issues - return []; - - /*const links = []; +export function extractFirstLink(text) { + const pattern = /(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/i; let inText = text; // strip out code blocks @@ -330,32 +323,12 @@ export function extractLinks(text) { // strip out inline markdown images inText = inText.replace(/!\[[^\]]*\]\([^\)]*\)/g, ''); - function replaceFn(autolinker, match) { - let link = ''; - const matchText = match.getMatchedText(); - - if (matchText.trim().indexOf('http') === 0) { - link = matchText; - } else { - link = 'http://' + matchText; - } - - links.push(link); + const match = pattern.exec(inText); + if (match) { + return match[0].trim(); } - Autolinker.link( - inText, - { - replaceFn, - urls: {schemeMatches: true, wwwMatches: true, tldMatches: false}, - emails: false, - twitter: false, - phone: false, - hashtag: false - } - ); - - return links;*/ + return ''; } export function escapeRegExp(string) { |