Files
dsh-purge2/lib/phase1-keep.js

22 lines
904 B
JavaScript

export const PHASE1_KEEP_EXPR =
'PERSONA_SECTION_NAMES.has(section?.name) || String(section?.name || "").startsWith("dsh-purge") || String(section?.name || "").startsWith("dshpg-")';
/**
* 把官方 phase-1 白名单放宽到 dsh-purge* + dshpg-*。
* 已放行 dsh-purge 的旧补丁会升到带 dshpg。
*/
export function widenPhase1KeepFilter(text) {
const raw = String(text || "");
const crlf = raw.includes("\r\n");
let next = raw.replace(/\r\n/g, "\n");
next = next.replace(
/PERSONA_SECTION_NAMES\.has\(section\?\.name\) \|\| String\(section\?\.name \|\| ""\)\.startsWith\("dsh-purge"\)(?! \|\| String\(section\?\.name \|\| ""\)\.startsWith\("dshpg-"\))/g,
PHASE1_KEEP_EXPR,
);
next = next.replace(
/section => PERSONA_SECTION_NAMES\.has\(section\?\.name\)(?! \|\|)/g,
`section => ${PHASE1_KEEP_EXPR}`,
);
return crlf ? next.replace(/\n/g, "\r\n") : next;
}