Repository navigation
fix(rules): restrict jQuery patterns to resource URLs - #31
Merged
Merged
Conversation
Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
审查者指南(小型 PR 中默认折叠)审查者指南此 PR 将现有 jQuery 规则的匹配范围限定为资源 URL,以消除对普通文本的误报,同时通过针对性的规则测试框架测试,保留对运行时全局变量和带版本号资源的检测。 文件级变更
提示与命令使用 Sourcery
自定义体验访问你的仪表板以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR narrows the existing jQuery rule to resource URLs to eliminate prose false positives, while retaining runtime-global and versioned resource detection through targeted rule-harness tests. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
7 tasks done
There was a problem hiding this comment.
嗨——我发现了 1 个问题
给 AI Agent 的提示
请处理这次代码审查中的评论:
## 单条评论
### 评论 1
<location path="tests/jquery-detection.test.mjs" line_range="7" />
<code_context>
+
+test('the extension detector rejects jQuery prose while preserving runtime and resource hits', async () => {
+ const rules = loadPageRules(['page/frontend-frameworks.json'])
+ const prose = await runPageDetector(rules, { html: '<p>A tutorial about jQuery.</p>' })
+ assert.ok(!prose.some(technology => technology.name === 'jQuery'))
+ const runtime = await runPageDetector(rules, { globals: ['jQuery'] })
</code_context>
<issue_to_address>
**教程标题仍会触发 jQuery 检测**
当页面标题包含“A tutorial about jQuery.”之类的描述性文本时,`detectFromDynamicSnapshot` 也会运行 `dynamicTechnologies` 中单独的 jQuery 规则;由于该规则没有 `matchIn`,`applyDynamicRuleList` 会搜索合并后的快照文本(包括标题),因此像“A tutorial about jQuery.”这样的标题也会被报告为 jQuery。注入式检测器的断言仍然会通过。
请同样将重复的 `dynamicTechnologies` jQuery 规则限制为仅匹配资源 URL,并添加回归测试覆盖该快照路径。
</issue_to_address>Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/jquery-detection.test.mjs" line_range="7" />
<code_context>
+
+test('the extension detector rejects jQuery prose while preserving runtime and resource hits', async () => {
+ const rules = loadPageRules(['page/frontend-frameworks.json'])
+ const prose = await runPageDetector(rules, { html: '<p>A tutorial about jQuery.</p>' })
+ assert.ok(!prose.some(technology => technology.name === 'jQuery'))
+ const runtime = await runPageDetector(rules, { globals: ['jQuery'] })
</code_context>
<issue_to_address>
**Tutorial titles still trigger jQuery**
When the page title contains prose such as “A tutorial about jQuery.”, `detectFromDynamicSnapshot` also runs the separate jQuery rule in `dynamicTechnologies`; because that rule has no `matchIn`, `applyDynamicRuleList` searches the combined snapshot text, including the title, and reports jQuery for a title such as “A tutorial about jQuery.” The injected-detector assertion still passes.
Restrict the duplicate `dynamicTechnologies` jQuery rule to resource URLs as well, and cover that snapshot path with a regression test.
</issue_to_address>Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
setube
added a commit
that referenced
this pull request
Oct 21, 2026
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.
1. Context & Motivation (Context)
jquery.and, withoutmatchIn, search page HTML or combined snapshot text. Ordinary body/title prose such asA tutorial about jQuery.is therefore reported as jQuery usage.2. Implementation Details (Implementation)
matchIn: ["resources"]to both existing jQuery rules; no matcher changes.3. Testing Strategies (Validation)
node --test tests/jquery-detection.test.mjs: both tests pass on this branch. The new dynamic-title regression failed before applying the resource scope.jQueryglobal still matches;jquery-3.7.1.min.jsstill reports version3.7.1.