fix(route/weibo/utils): enforce tvax sinaimg CDN (#11533)

Signed-off-by: Rongrong <i@rong.moe>

Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
Rongrong
2023-01-01 23:30:08 +08:00
committed by GitHub
parent fe560d28fb
commit d0747e319a
+7 -6
View File
@@ -425,12 +425,13 @@ const weiboUtils = {
sinaimgTvax: (() => {
// https://datatracker.ietf.org/doc/html/rfc1808#section-2.4.3
const regex = /(?<=\/\/)wx(?=[1-4]\.sinaimg\.cn\/)/gi;
const prefixes = ['tva', 'tvax'];
let cnt = 0;
const replace = (html) => {
cnt = (cnt + 1) % 2;
return html.replace(regex, prefixes[cnt]);
};
// const prefixes = ['tva', 'tvax'];
// let cnt = 0;
// const replace = (html) => {
// cnt = (cnt + 1) % 2;
// return html.replace(regex, prefixes[cnt]);
// };
const replace = (html) => html.replace(regex, 'tvax'); // enforce `tvax` as `tva` has a strict WAF
const replaceKV = (obj, keys) => {
keys.forEach((key) => {
if (obj[key]) {