@befe/vault-system 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +1 -1
- package/package.json +1 -1
- package/src/core/ctag.ts +7 -0
package/INSTALL.md
CHANGED
package/package.json
CHANGED
package/src/core/ctag.ts
CHANGED
|
@@ -55,9 +55,16 @@ export function parseAll(text: string): ParsedCtag[] {
|
|
|
55
55
|
* - 裸键核心:260920_g0g8m
|
|
56
56
|
* - 仅 5 位 hash:g0g8m(date 未知,按 hash 匹配)
|
|
57
57
|
* 返回 { keyCore?, hash },keyCore 优先精确匹配,否则退化到 hash-only 匹配。
|
|
58
|
+
* 优先级:带 `_ctag` 尾巴的稳定键 > 任意「日期_5位」片段 > 纯 hash。
|
|
58
59
|
*/
|
|
59
60
|
export function normalizeQuery(input: string): { keyCore?: string; hash?: string } {
|
|
60
61
|
const trimmed = input.trim();
|
|
62
|
+
// 先认带 `_ctag` 尾巴的稳定键,且取最后一段:descr 里可能自带形如 260826_prize 的片段,
|
|
63
|
+
// 直接取第一个「日期_5位」会被 descr 抢先,拿一个不存在的 key 去查(见 log 261102 的 bug)。
|
|
64
|
+
let suffix: RegExpExecArray | null = null;
|
|
65
|
+
for (const m of trimmed.matchAll(/(\d{6})_([0-9a-z]{5})_ctag/g)) suffix = m;
|
|
66
|
+
if (suffix) return { keyCore: `${suffix[1]}_${suffix[2]}`, hash: suffix[2] };
|
|
67
|
+
// 没有任何 `_ctag` 尾巴时(裸核心键 / 省略了 ctag 的完整串)退回原来的宽松匹配
|
|
61
68
|
const full = trimmed.match(/(\d{6})_([0-9a-z]{5})/);
|
|
62
69
|
if (full) return { keyCore: `${full[1]}_${full[2]}`, hash: full[2] };
|
|
63
70
|
const hashOnly = trimmed.match(/^([0-9a-z]{5})$/);
|