本文整理匯總了TypeScript中escape-html類的典型用法代碼示例。如果您正苦於以下問題:TypeScript escape-html類的具體用法?TypeScript escape-html怎麽用?TypeScript escape-html使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了escape-html類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: InsertEmbedsPostmark
public InsertEmbedsPostmark(content: string, msg: Discord.Message): string {
for (const embed of msg.embeds) {
if (embed.title === undefined && embed.description === undefined) {
continue;
}
if (this.isEmbedInBody(msg, embed)) {
continue;
}
let embedContent = "<hr>"; // Horizontal rule. Two to make sure the content doesn't become a title.
const embedTitle = embed.url ?
`<a href="${escapeHtml(embed.url)}">${escapeHtml(embed.title)}</a>`
: escapeHtml(embed.title);
if (embedTitle) {
embedContent += `<h5>${embedTitle}</h5>`; // h5 is probably best.
}
if (embed.description) {
embedContent += markdown.toHTML(embed.description, {
discordCallback: this.getDiscordParseCallbacksHTML(msg),
embed: true,
});
}
content += embedContent;
}
return content;
}
示例2: InsertUser
public InsertUser(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const member = msg.guild.members.get(id);
const memberId = `@_discord_${id}:${this.opts.domain}`;
const memberName = member ? member.displayName : memberId;
if (!html) {
return memberName;
}
return `<a href="${MATRIX_TO_LINK}${escapeHtml(memberId)}">${escapeHtml(memberName)}</a>`;
}
示例3: InsertChannel
public InsertChannel(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const channel = msg.guild.channels.get(id);
if (!channel) {
return html ? `<#${escapeHtml(id)}>` : `<#${id}>`;
}
const channelStr = escapeHtml(channel ? "#" + channel.name : "#" + id);
if (!html) {
return channelStr;
}
const roomId = escapeHtml(`#_discord_${msg.guild.id}_${id}:${this.opts.domain}`);
return `<a href="${MATRIX_TO_LINK}${roomId}">${escapeHtml(channelStr)}</a>`;
}
示例4: InsertEmoji
public InsertEmoji(node: IEmojiNode): string {
// unfortunately these callbacks are sync, so we flag our url with some special stuff
// and later on grab the real url async
const FLAG = "\x01";
const name = escapeHtml(node.name);
return `${FLAG}${name}${FLAG}${node.animated ? 1 : 0}${FLAG}${node.id}${FLAG}`;
}
示例5: send
(error: send.SendError) => {
if (error.status === 404 && !filePathRegex.test(filePath)) {
// The static file handling middleware failed to find a file on
// disk. Serve the entry point HTML file instead of a 404.
send(req, entrypoint, {root: root}).pipe(res);
} else {
res.status(error.status || 500);
res.type('html');
res.end(escapeHtml(error.message));
}
})
示例6: InsertRole
public InsertRole(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const role = msg.guild.roles.get(id);
if (!role) {
return html ? `<@&${id}>` : `<@&${id}>`;
}
if (!html) {
return `@${role.name}`;
}
const color = Util.NumberToHTMLColor(role.color);
return `<span data-mx-color="${color}"><strong>@${escapeHtml(role.name)}</strong></span>`;
}
示例7: function
redisClient.get(escape(id), function (err, reply) {
if (err) return errorHandler.handleError(res, err);
if (!reply) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se pudo cargar la imagen " + id);
}
req.image = {
id: escape(id),
image: reply
};
next();
});
示例8: findByID
export function findByID(req: IFindByIdRequest, res: express.Response, next: NextFunction) {
const id = req.params.imageId;
redisClient.get(escape(id), function (err, reply) {
if (err) return errorHandler.handleError(res, err);
if (!reply) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se pudo cargar la imagen " + id);
}
req.image = {
id: escape(id),
image: reply
};
next();
});
}
示例9: fillProvinceIfPresent
export function fillProvinceIfPresent(req: IFindProvince, res: express.Response, next: NextFunction) {
// Si no viene ninguna provincia definida, no hacemos nada
if (!req.body.province) {
return next();
}
Province.findOne({
_id: escape(req.body.province),
enabled: true
},
function (err, province) {
if (err) return errorHandler.handleError(res, err);
if (!province) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se encuentra la provincia " + req.body.province);
}
req.province = province;
next();
});
}
示例10: FormatEdit
public async FormatEdit(
oldMsg: Discord.Message,
newMsg: Discord.Message,
link?: string,
): Promise<DiscordMessageProcessorResult> {
oldMsg.embeds = []; // we don't want embeds on old msg
const oldMsgParsed = await this.FormatMessage(oldMsg);
const newMsgParsed = await this.FormatMessage(newMsg);
const result = new DiscordMessageProcessorResult();
result.body = `*edit:* ~~${oldMsgParsed.body}~~ -> ${newMsgParsed.body}`;
result.msgtype = newMsgParsed.msgtype;
oldMsg.content = `*edit:* ~~${oldMsg.content}~~ -> ${newMsg.content}`;
const linkStart = link ? `<a href="${escapeHtml(link)}">` : "";
const linkEnd = link ? "</a>" : "";
if (oldMsg.content.includes("\n") || newMsg.content.includes("\n")
|| newMsg.content.length > MAX_EDIT_MSG_LENGTH) {
result.formattedBody = `<p>${linkStart}<em>edit:</em>${linkEnd}</p><p><del>${oldMsgParsed.formattedBody}` +
`</del></p><hr><p>${newMsgParsed.formattedBody}</p>`;
} else {
result.formattedBody = `${linkStart}<em>edit:</em>${linkEnd} <del>${oldMsgParsed.formattedBody}</del>` +
` -> ${newMsgParsed.formattedBody}`;
}
return result;
}