fix(route/{telegram/channel,wechat/tgchannel}): broken links (#15332)
route/telegram/channel: Since 2024/4/20, t.me/s/ mistakenly have every '&' in **hyperlinks** replaced by '&'. The characteristic of a hyperlink is [onclick] (pop-up confirmation), which is not present in ordinary links. This is a workaround to fix the issue until Telegram fixes it. route/wechat/tgchannel: Since 2024/4/20, t.me/s/ mistakenly have every '&' in **hyperlinks** replaced by '&'. wechat-mp will take care of this, so no need to fix it here. However, once the bug is eventually fixed, all guid will be changed again. Considering that this is almost certain to happen, let's break guid consistency now by using normalized URL from wechat-mp as guid to avoid similar issues in the future. Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
parent
d2e8cd65c5
commit
690e91c59d
|
|
@ -159,6 +159,18 @@ async function handler(ctx) {
|
|||
);
|
||||
|
||||
const $ = load(data);
|
||||
|
||||
/*
|
||||
* Since 2024/4/20, t.me/s/ mistakenly have every '&' in **hyperlinks** replaced by '&'.
|
||||
* The characteristic of a hyperlink is [onclick] (pop-up confirmation), which is not present in ordinary links.
|
||||
* This is a workaround to fix the issue until Telegram fixes it.
|
||||
*/
|
||||
$('a[onclick][href]').each((_, elem) => {
|
||||
const $elem = $(elem);
|
||||
const href = $elem.attr('href');
|
||||
href && $elem.attr('href', href.replaceAll('&', '&'));
|
||||
});
|
||||
|
||||
const list = includeServiceMsg
|
||||
? $('.tgme_widget_message_wrap:not(.tgme_widget_message_wrap:has(.tme_no_messages_found))') // exclude 'no posts found' messages
|
||||
: $('.tgme_widget_message_wrap:not(.tgme_widget_message_wrap:has(.service_message,.tme_no_messages_found))'); // also exclude service messages
|
||||
|
|
|
|||
|
|
@ -149,11 +149,18 @@ async function handler(ctx) {
|
|||
|
||||
const pubDate = new Date(item.find('.tgme_widget_message_date time').attr('datetime')).toUTCString();
|
||||
|
||||
/*
|
||||
* Since 2024/4/20, t.me/s/ mistakenly have every '&' in **hyperlinks** replaced by '&'.
|
||||
* wechat-mp will take care of this, so no need to fix it here.
|
||||
* However, once the bug is eventually fixed, all guid will be changed again.
|
||||
* Considering that this is almost certain to happen, let's break guid consistency now by using
|
||||
* normalized URL from wechat-mp as guid to avoid similar issues in the future.
|
||||
*/
|
||||
const single = {
|
||||
title,
|
||||
pubDate,
|
||||
link,
|
||||
guid: link,
|
||||
// guid: link,
|
||||
};
|
||||
|
||||
if (link !== undefined) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue