Merge pull request #2602 from ZBoxApp/autolinker

Replace Autolinker in extractLinks with a pattern
Этот коммит содержится в:
Harrison Healey
2016-04-01 15:05:54 -04:00
родитель d9d6a0c783 9ec459526a
Коммит a427d61b33
2 изменённых файлов: 7 добавлений и 34 удалений

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

@@ -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) {