summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webapp/components/post_body_additional_content.jsx2
-rw-r--r--webapp/utils/utils.jsx39
-rw-r--r--webapp/webpack.config.js4
3 files changed, 10 insertions, 35 deletions
diff --git a/webapp/components/post_body_additional_content.jsx b/webapp/components/post_body_additional_content.jsx
index 2cd82f213..452597dde 100644
--- a/webapp/components/post_body_additional_content.jsx
+++ b/webapp/components/post_body_additional_content.jsx
@@ -70,7 +70,7 @@ export default class PostBodyAdditionalContent extends React.Component {
return this.getSlackAttachment();
}
- const link = Utils.extractLinks(this.props.post.message)[0];
+ const link = Utils.extractFirstLink(this.props.post.message);
if (!link) {
return null;
}
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index ccdc00ea5..9b03ef32a 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) {
diff --git a/webapp/webpack.config.js b/webapp/webpack.config.js
index 478c5de81..4e2d6b70d 100644
--- a/webapp/webpack.config.js
+++ b/webapp/webpack.config.js
@@ -77,7 +77,9 @@ var config = {
}),
htmlExtract,
new CopyWebpackPlugin([
- {from: 'images/emoji', to: 'emoji'}
+ {from: 'images/emoji', to: 'emoji'},
+ {from: 'images/logo-email.png', to: 'images'},
+ {from: 'images/circles.png', to: 'images'}
]),
new webpack.LoaderOptionsPlugin({
minimize: !DEV,