feat: 增强弹幕屏蔽词解析与生效诊断日志 - #453
Merged
Merged
Conversation
- 重写 BLOCKED_WORDS 解析器:支持 /regex/flags 正则词条与纯文本词条混用,兼容中英文逗号(,/,)及逗号前后空格;正则词条内部的逗号不再被误切分 - 正则词条支持 i/m/s/u 等标志;自动剥离 g/y 标志避免 lastIndex 状态污染 - 非法正则自动降级为字面量匹配并输出警告,不再静默丢弃整条规则 - 新增生效诊断日志:规则解析结果、拦截总数/每条规则命中次数、拦截示例、无命中提示、配置无效警告,便于用户确认屏蔽词是否实际生效 - 更新 README 中 BLOCKED_WORDS 说明与示例 - 新增 test_blocked_words.mjs 覆盖 7 类解析场景(7/7 通过)
|
@xlmc is attempting to deploy a commit to the huangxd's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
佬,TITLE_MAPPING_TABLE_URL_CACHE_MINUTES和TITLE_MAPPING_TABLE_URL的逻辑实现了吗?我好像没找到? |
Contributor
Author
|
这个我是本地加诊断日志的分类。没有传😂只修了弹幕关键字屏蔽。要撤回重发么在 2026年8月22日,00:28,huangxd- ***@***.***> 写道:huangxd- left a comment (huangxd-/danmu_api#453)
佬,TITLE_MAPPING_TABLE_URL_CACHE_MINUTES和TITLE_MAPPING_TABLE_URL的逻辑实现了吗?我好像没找到?
—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Owner
是的,把多余的删了吧 |
- 删除 README 中 TITLE_MAPPING_TABLE_URL / TITLE_MAPPING_TABLE_URL_CACHE_MINUTES 两条配置说明(对应功能未包含在本 PR) - test_blocked_words.mjs 的 7 类屏蔽词解析场景合并进 danmu_api/worker.test.js,删除独立测试文件(38/38 通过)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
当前 BLOCKED_WORDS 屏蔽词功能存在两个痛点:
split(/(?<=\/),(?=\/)/)切分,要求所有规则必须严格写成/a/,/b/格式。用户写纯文本词(如签到,打卡)时,整串会被当作一个无效正则静默丢弃,屏蔽词完全不生效且无任何提示;正则内部含逗号(如/a{1,2},b/)也会被误切分。改动内容
解析器重写(
danmu_api/utils/danmu-util.js)splitBlockedWords():状态机式切分器/pattern/flags词条整体识别(词条内部的逗号、转义斜杠\/不作为分隔符)/等无法构成合法正则的片段按普通文本处理parseBlockedWord():单条规则转换/pattern/或/pattern/i,m,s,u按正则解析(自动剥离 g/y 标志,避免 lastIndex 状态污染 test 结果)生效诊断日志
/打卡/ ×511, /签到/ ×49)、最多 3 条拦截示例(弹幕内容 ← 命中规则)文档与测试
danmu_api/worker.test.js中新增 BLOCKED_WORDS 测试:覆盖纯文本词、中英文逗号混用、正则+文本混合、正则内逗号、flags 剥离、非法正则降级等 7 类场景测试
node danmu_api/worker.test.js→ 38/38 通过(含新增屏蔽词测试,无回归)