Source

dom/parseUrlsInHTMLStr.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_URL_REPLACER_STR = void 0;
var replaceUrlsInHTMLStr_1 = __importDefault(require("./replaceUrlsInHTMLStr"));
exports.DEFAULT_URL_REPLACER_STR = '<a href=\"$1\">$1</a>';
/**
 * Wrap URLs in HTML string with anchor tags
 *
 * @param text
 * @param isHTML
 * @category dom
 * @module parseUrlsInHTMLStr
 */
var parseUrlsInHTMLStr = function (htmlStr, replacer) {
    if (replacer === void 0) { replacer = exports.DEFAULT_URL_REPLACER_STR; }
    return (0, replaceUrlsInHTMLStr_1.default)(htmlStr, replacer)
        // * Prevent www at start makes url invalid
        .replace(/\<a\shref\=\"www\.(.+)\"\>/g, '<a href="http://www.$1">');
};
exports.default = parseUrlsInHTMLStr;