Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import _ from 'lodash'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import Autolinker from 'autolinker'
import twemoji from 'twemoji'
import emoji from '../emoji'
import chat from '../stores/chat'
import hueHash from '../hue-hash'
import heimURL from '../heim-url'
const autolinker = new Autolinker({
twitter: false,
truncate: 40,
replaceFn(self, match) {
if (match.getType() === 'url') {
const url = match.getUrl()
const tag = self.getTagBuilder().build(match)
if (/^javascript/.test(url.toLowerCase())) {
// Thanks, Jordan!
return false
}
if (location.protocol === 'https:' && RegExp('^https?:\/\/' + location.hostname).test(url)) {
// self-link securely
tag.setAttr('href', url.replace(/^http:/, 'https:'))
} else {
function AutoLinker(message) {
if (RocketChat.settings.get('AutoLinker') !== true) {
return message;
}
if (s.trim(message.html)) {
const regUrls = new RegExp(RocketChat.settings.get('AutoLinker_UrlsRegExp'));
const autolinker = new Autolinker({
stripPrefix: RocketChat.settings.get('AutoLinker_StripPrefix'),
urls: {
schemeMatches: RocketChat.settings.get('AutoLinker_Urls_Scheme'),
wwwMatches: RocketChat.settings.get('AutoLinker_Urls_www'),
tldMatches: RocketChat.settings.get('AutoLinker_Urls_TLD'),
},
email: RocketChat.settings.get('AutoLinker_Email'),
phone: RocketChat.settings.get('AutoLinker_Phone'),
twitter: false,
stripTrailingSlash: false,
replaceFn(match) {
if (match.getType() === 'url') {
if (regUrls.test(match.matchedText)) {
if (match.matchedText.indexOf(Meteor.absoluteUrl()) === 0) {
// returns an `Autolinker.HtmlTag` instance for an <a> tag
const tag = match.buildTag();</a>
'use strict'
import React from 'react'
import Autolinker from 'autolinker'
const autolinker = new Autolinker()
// Returns a React element or a string
function reactAutoLink (word, options, wordIndex) {
const tag = autolinker.parse(word).map(i => i.buildTag())[0]
if (!tag) return word
return React.createElement(
tag.getTagName(),
Object.assign(tag.attrs, { key: `${tag.attrs.href}-${wordIndex}` }, options),
tag.getInnerHTML()
)
}
export default reactAutoLink
}
if (!regUrls.test(match.matchedText)) {
return null;
}
if (match.matchedText.indexOf(Meteor.absoluteUrl()) === 0) {
const tag = match.buildTag();
tag.setAttr('target', '');
return tag;
}
return true;
};
return new Autolinker({
stripPrefix: settings.get('AutoLinker_StripPrefix'),
urls: {
schemeMatches: settings.get('AutoLinker_Urls_Scheme'),
wwwMatches: settings.get('AutoLinker_Urls_www'),
tldMatches: settings.get('AutoLinker_Urls_TLD'),
},
email: settings.get('AutoLinker_Email'),
phone: settings.get('AutoLinker_Phone'),
twitter: false,
stripTrailingSlash: false,
replaceFn: replaceAutolinkerMatch,
});
};
}
if (!regUrls.test(match.matchedText)) {
return null;
}
if (match.matchedText.indexOf(Meteor.absoluteUrl()) === 0) {
const tag = match.buildTag();
tag.setAttr('target', '');
return tag;
}
return true;
};
return new Autolinker({
stripPrefix: settings.get('AutoLinker_StripPrefix'),
urls: {
schemeMatches: settings.get('AutoLinker_Urls_Scheme'),
wwwMatches: settings.get('AutoLinker_Urls_www'),
tldMatches: settings.get('AutoLinker_Urls_TLD'),
},
email: settings.get('AutoLinker_Email'),
phone: settings.get('AutoLinker_Phone'),
twitter: false,
stripTrailingSlash: false,
replaceFn: replaceAutolinkerMatch,
});
};
import Autolinker from 'autolinker';
this.livechatAutolinker = new Autolinker({
twitter: false,
phone: false,
});
import Autolinker from 'autolinker';
import React from 'react';
const autolinker = new Autolinker({
stripPrefix: false,
stripTrailingSlash: false
});
export default function linkify(text) {
if (!text) {
return text;
}
let matches = autolinker.parseText(text);
if (matches.length === 0) {
return text;
}
const result = [];
render() {
const { children, autolink, isOwn } = this.props;
if (!autolink) {
return (
{children}
);
}
let autolinker = new Autolinker( {
urls : {
schemeMatches : true,
wwwMatches : true,
tldMatches : true
},
email : true,
phone : true,
mention : false,
hashtag : false,
stripPrefix : false,
stripTrailingSlash : true,
newWindow : true,
truncate : {
length : 0,