"include/git@code.vereign.com:docker/osticket.git" did not exist on "b7091391c5d50d77ee1e277a0b7b868b0c28c03b"
Newer
Older
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanupHiddenCharacters = exports.cleanupImageText = exports.normalizePlainPart = void 0;
// this is a Node module. require is a must to work across different envs
const URL = require("url-parse");
const defaultOptions = {
normalizeImagePlain: true,
};
const normalizePlainPart = (text, options) => {
options = options
? Object.assign(defaultOptions, Object.assign({}, options))
: defaultOptions;
if (options === null || options === void 0 ? void 0 : options.sealUrl) {
text = removeSeal(text, options.sealUrl);
}
if (options === null || options === void 0 ? void 0 : options.normalizeImagePlain) {
text = exports.cleanupImageText(text);
text = utils_1.normalizeTextSpacings(text);
return text.trim();
const patchOutlookSafelinksWrappers = (text) => {
const links = text.match(/<https:.+?(safelinks\.protection\.outlook\.com).+?>/g);
if (links) {
links.forEach((link) => {
const url = new URL(link.slice(1, link.length - 1), true);
const originalUrl = url.query["url"];
text = text.replace(link, `<${originalUrl}>`);
});
}
return text;
};
const removeSeal = (plain, sealUrl) => {
// For cases [<image-alt>]<<seal-url>>
const sealRegex = `\\[.+?]\\s*<${sealUrl}>`;
// For cases <<seal-url>>[<image-alt>]
const sealRegexReversed = `<${sealUrl}>\\s*\\[.+?]`;
return plain
.replace(new RegExp(sealRegex), "")
.replace(new RegExp(sealRegexReversed), "");
const cleanupImageText = (plain) => {
// For cases [image: IMAGE_NAME.EXTENSION]
const sealRegex = `\\[(image:\\s)(.*)\\]`;
return plain.replace(new RegExp(sealRegex), "[$2]");
};