From c93226cdffc6d3233f43796ca736a6c20fd446fb Mon Sep 17 00:00:00 2001 From: tmr <32825326+ttttmr@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:18:59 +0800 Subject: [PATCH] feat: make url clickable (#14353) --- lib/v2/jike/topic.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/v2/jike/topic.js b/lib/v2/jike/topic.js index 3aca515f6905d3..370151665a2f9c 100644 --- a/lib/v2/jike/topic.js +++ b/lib/v2/jike/topic.js @@ -4,6 +4,8 @@ const cheerio = require('cheerio'); const dayjs = require('dayjs'); const { constructTopicEntry } = require('@/v2/jike/utils'); +const urlRegex = /(https?:\/\/[^\s"'<>]+)/g; + module.exports = async (ctx) => { const id = ctx.params.id; const topicUrl = `https://m.okjike.com/topics/${id}`; @@ -33,6 +35,7 @@ module.exports = async (ctx) => { return description; }); } + item.description = item.description.replaceAll(urlRegex, (url) => `${url}`); item.title = `${data.topic.content} ${dayjs(one.pubDate).format('MM月DD日')}`; return item; })