summaryrefslogtreecommitdiffstats
path: root/webapp/utils/utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils/utils.jsx')
-rw-r--r--webapp/utils/utils.jsx39
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) {