Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import moment from 'moment/moment';
import numeral from 'numeral';
import { isString, isArray, isUndefined, isFinite, isNil, toString } from 'lodash';
numeral.options.scalePercentBy100 = false;
// eslint-disable-next-line
const urlPattern = /(^|[\s\n]|)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function createTextFormatter(highlightLinks) {
if (highlightLinks) {
return (value) => {
if (isString(value)) {
value = value.replace(urlPattern, '$1<a href="$2">$2</a>');
}
return toString(value);
};
}
return value => toString(value);