fix(ena-planner): harden url/think cleanup and remove hardcoded vars
This commit is contained in:
@@ -226,7 +226,10 @@ function buildUrl(path) {
|
|||||||
const p = prefix.startsWith('/') ? prefix : `/${prefix}`;
|
const p = prefix.startsWith('/') ? prefix : `/${prefix}`;
|
||||||
const finalPrefix = p.replace(/\/+$/g, '');
|
const finalPrefix = p.replace(/\/+$/g, '');
|
||||||
const finalPath = path.startsWith('/') ? path : `/${path}`;
|
const finalPath = path.startsWith('/') ? path : `/${path}`;
|
||||||
return `${base}${finalPrefix}${finalPath}`;
|
const escapedPrefix = finalPrefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
const hasSameSuffix = !!finalPrefix && new RegExp(`${escapedPrefix}$`, 'i').test(base);
|
||||||
|
const normalizedBase = hasSameSuffix ? base.slice(0, -finalPrefix.length) : base;
|
||||||
|
return `${normalizedBase}${finalPrefix}${finalPath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSendUIBusy(busy) {
|
function setSendUIBusy(busy) {
|
||||||
@@ -304,15 +307,11 @@ function formatCharCardBlock(charObj) {
|
|||||||
function cleanAiMessageText(text) {
|
function cleanAiMessageText(text) {
|
||||||
let out = String(text ?? '');
|
let out = String(text ?? '');
|
||||||
|
|
||||||
// 1) Strip everything before and including </think> (handles unclosed think blocks)
|
// 1) Strip properly wrapped <think>/<thinking> blocks only.
|
||||||
// Pattern: content without opening <think> followed by </think>
|
|
||||||
out = out.replace(/^[\s\S]*?<\/think>/i, '');
|
|
||||||
|
|
||||||
// 2) Also strip properly wrapped <think>...</think> blocks
|
|
||||||
out = out.replace(/<think\b[^>]*>[\s\S]*?<\/think>/gi, '');
|
out = out.replace(/<think\b[^>]*>[\s\S]*?<\/think>/gi, '');
|
||||||
out = out.replace(/<thinking\b[^>]*>[\s\S]*?<\/thinking>/gi, '');
|
out = out.replace(/<thinking\b[^>]*>[\s\S]*?<\/thinking>/gi, '');
|
||||||
|
|
||||||
// 3) Strip user-configured exclude tags
|
// 2) Strip user-configured exclude tags
|
||||||
// NOTE: JS \b does NOT work after CJK characters, so we use [^>]*> instead.
|
// NOTE: JS \b does NOT work after CJK characters, so we use [^>]*> instead.
|
||||||
// Order matters: try block match first (greedy), then mop up orphan open/close tags.
|
// Order matters: try block match first (greedy), then mop up orphan open/close tags.
|
||||||
const s = ensureSettings();
|
const s = ensureSettings();
|
||||||
@@ -734,17 +733,8 @@ function buildEjsContext() {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute common derived values that entries might reference
|
|
||||||
const fire = Number(getvar('stat_data.蒂娜.火')) || 0;
|
|
||||||
const ice = Number(getvar('stat_data.蒂娜.冰')) || 0;
|
|
||||||
const dark = Number(getvar('stat_data.蒂娜.暗')) || 0;
|
|
||||||
const light = Number(getvar('stat_data.蒂娜.光')) || 0;
|
|
||||||
const maxAttrValue = Math.max(fire, ice, dark, light);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getvar, setvar,
|
getvar, setvar,
|
||||||
fire, ice, dark, light,
|
|
||||||
maxAttrValue,
|
|
||||||
Number, Math, JSON, String, Array, Object, parseInt, parseFloat,
|
Number, Math, JSON, String, Array, Object, parseInt, parseFloat,
|
||||||
console: { log: () => { }, warn: () => { }, error: () => { } },
|
console: { log: () => { }, warn: () => { }, error: () => { } },
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user