From 05da67fc2aebdd5cd0138f6ead41e5abfd2dd90a Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 7 Nov 2026 05:17:59 +0800 Subject: [PATCH 1/2] Update search.js --- website/templates/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/templates/search.js b/website/templates/search.js index 963c389d..1da41080 100644 --- a/website/templates/search.js +++ b/website/templates/search.js @@ -164,7 +164,7 @@ normalize(text.replace(QUESTION, ' ')).split(' ').forEach(function (word) { (word.match(/[㐀-鿿豈-﫿]+|[^㐀-鿿豈-﫿]+/g) || []).forEach(function (part) { if (CJK.test(part)) { - for (var i = 0; i + 1 < part.length; i++) if (!FUNCTION_CHARS.test(part.slice(i, i + 2))) units.push([part.slice(i, i + 2)]); + for (var i = 0; i + 1 < part.length; i++) if (!FUNCTION_CHARS.test(part.slice(i, i + 2))) units.push(alternatives(part.slice(i, i + 2))); } else { // 英文和数字按词切开,标点(“、”“,”)不算词的一部分:“http/1.0、2.0”是两个词 (part.match(/[a-z0-9][a-z0-9+#./_-]*/g) || []).forEach(function (token) { From 67d01f337b129a5ddc1bba48806f979be40fb783 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 7 Nov 2026 05:17:59 +0800 Subject: [PATCH 2/2] Update test_search.cjs --- website/builder/test_search.cjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/builder/test_search.cjs b/website/builder/test_search.cjs index 8a212ec7..17e9fb5a 100644 --- a/website/builder/test_search.cjs +++ b/website/builder/test_search.cjs @@ -106,6 +106,16 @@ const asking = { documents: [ assert.equal(search(asking, '堆和栈的区别是什么?')[0].id, 'diff', '去掉问句的开头结尾后正好是小节标题'); assert.equal(search(asking, '了解juc吗?')[0].id, 'aqs', 'JUC 与 J.U.C 互通'); assert.equal(search(asking, '跳跃表')[0].id, 'skip', '跳跃表与跳表互通'); +const skiplist = { documents: [ + { title: 'Redis', path: '/notes/Redis', sections: [{ title: '跳跃表', id: 'skip', text: '有序集合的底层实现之一,插入时随机决定节点的层数' }] }, + { title: '攻击技术', path: '/notes/攻击技术', sections: [ + { title: '设置 Cookie 为 HttpOnly', id: 'cookie', text: '设置后脚本无法读取 Cookie' }, + { title: '设置 Cookie 的 SameSite 属性', id: 'samesite', text: '设置为 Strict 时跨站请求不携带 Cookie' }, + ] }, + { title: 'Linux', path: '/notes/Linux', sections: [{ title: '环境变量', id: 'env', text: '在配置文件中设置' }] }, + { title: 'MySQL', path: '/notes/MySQL', sections: [{ title: '参数', id: 'param', text: '设置缓冲池大小' }] }, +] }; +assert.equal(search(skiplist, '跳表的层高怎么设置')[0].id, 'skip', '整句里的“跳表”也能匹配标题“跳跃表”'); const versions = { documents: [{ title: 'HTTP', path: '/notes/HTTP', sections: [ { title: '八、HTTP/2.0', id: 'h2', text: '二进制分帧、多路复用、首部压缩' }, { title: '七、HTTP/1.1 新特性', id: 'h11', text: '默认长连接' },