Replace Autolinker in extractLinks with a pattern

Этот коммит содержится в:
Elias Nahum
2016-03-31 18:16:55 -03:00
родитель 36f611fac4
Коммит ff01fc7337

Просмотреть файл

@@ -14,7 +14,6 @@ var ActionTypes = Constants.ActionTypes;
import * as Client from './client.jsx'; import * as Client from './client.jsx';
import * as AsyncClient from './async_client.jsx'; import * as AsyncClient from './async_client.jsx';
import * as client from './client.jsx'; import * as client from './client.jsx';
import Autolinker from 'autolinker';
import React from 'react'; import React from 'react';
import {browserHistory} from 'react-router'; import {browserHistory} from 'react-router';
@@ -315,13 +314,8 @@ export function getTimestamp() {
// extracts links not styled by Markdown // extracts links not styled by Markdown
export function extractLinks(text) { export function extractLinks(text) {
text; // eslint-disable-line no-unused-expressions const pattern = /(^|[\s\n]|<br\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
Autolinker; // eslint-disable-line no-unused-expressions let links;
// skip this operation because autolinker is having issues
return [];
/*const links = [];
let inText = text; let inText = text;
// strip out code blocks // strip out code blocks
@@ -330,32 +324,13 @@ export function extractLinks(text) {
// strip out inline markdown images // strip out inline markdown images
inText = inText.replace(/!\[[^\]]*\]\([^\)]*\)/g, ''); inText = inText.replace(/!\[[^\]]*\]\([^\)]*\)/g, '');
function replaceFn(autolinker, match) { links = inText.match(pattern) || [];
let link = '';
const matchText = match.getMatchedText();
if (matchText.trim().indexOf('http') === 0) { return links.map(
link = matchText; (url) => {
} else { return url.trim();
link = 'http://' + matchText;
}
links.push(link);
}
Autolinker.link(
inText,
{
replaceFn,
urls: {schemeMatches: true, wwwMatches: true, tldMatches: false},
emails: false,
twitter: false,
phone: false,
hashtag: false
} }
); );
return links;*/
} }
export function escapeRegExp(string) { export function escapeRegExp(string) {