當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript escape-html類代碼示例

本文整理匯總了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;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:25,代碼來源:discordmessageprocessor.ts

示例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>`;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:10,代碼來源:discordmessageprocessor.ts

示例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 ? `&lt;#${escapeHtml(id)}&gt;` : `<#${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>`;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:13,代碼來源:discordmessageprocessor.ts

示例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}`;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:7,代碼來源:discordmessageprocessor.ts

示例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));
   }
 })
開發者ID:poehlmann,項目名稱:EvaluacionDiferencialDeLaMemoria,代碼行數:11,代碼來源:start_server.ts

示例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 ? `&lt;@&amp;${id}&gt;` : `<@&${id}>`;
     }
     if (!html) {
         return `@${role.name}`;
     }
     const color = Util.NumberToHTMLColor(role.color);
     return `<span data-mx-color="${color}"><strong>@${escapeHtml(role.name)}</strong></span>`;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:12,代碼來源:discordmessageprocessor.ts

示例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();
  });
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:13,代碼來源:image.service.ts

示例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();
  });
}
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:17,代碼來源:image.service.ts

示例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();
    });
}
開發者ID:maticorv,項目名稱:mascotas2018_foro,代碼行數:21,代碼來源:profile.service.ts

示例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>` +
             ` -&gt; ${newMsgParsed.formattedBody}`;
     }
     return result;
 }
開發者ID:Half-Shot,項目名稱:matrix-appservice-discord,代碼行數:24,代碼來源:discordmessageprocessor.ts


注:本文中的escape-html類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。