-
-
Notifications
You must be signed in to change notification settings - Fork 44
feat: support OR keyword in search tags #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlejandroAkbal
wants to merge
3
commits into
main
Choose a base branch
from
auto-triage/2-feature-or-search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| export function normalizeSearchTagInput(rawValue: string) { | ||
| if (!rawValue) { | ||
| return '' | ||
| } | ||
|
|
||
| let value = rawValue.trim() | ||
|
|
||
| // Collapse one or more OR tokens (case-insensitive) into a comma — the OR-group delimiter | ||
| value = value.replace(/\s*(?:\bor\b(?:\s+)?)+\s*/gi, ',') | ||
|
|
||
| // Replace remaining spaces (within individual tag names) with underscores | ||
| value = value.replace(/\s/g, '_') | ||
|
|
||
| return value | ||
| } | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { normalizeSearchTagInput } from '../../assets/js/SearchTagInputHelper' | ||
|
|
||
| describe('normalizeSearchTagInput', () => { | ||
| it('maps typed OR separators to commas case-insensitively', () => { | ||
| expect(normalizeSearchTagInput('cat OR dog')).toBe('cat,dog') | ||
| expect(normalizeSearchTagInput('cat or dog')).toBe('cat,dog') | ||
| expect(normalizeSearchTagInput('cat Or dog')).toBe('cat,dog') | ||
| expect(normalizeSearchTagInput('cat oR dog')).toBe('cat,dog') | ||
| }) | ||
|
|
||
| it('maps multiple OR separators to commas', () => { | ||
| expect(normalizeSearchTagInput('cat OR dog or fish')).toBe('cat,dog,fish') | ||
| }) | ||
|
|
||
| it('preserves existing behavior of converting spaces in tags to underscores', () => { | ||
| expect(normalizeSearchTagInput('black hair')).toBe('black_hair') | ||
| expect(normalizeSearchTagInput('black hair OR blue eyes')).toBe('black_hair,blue_eyes') | ||
| }) | ||
|
|
||
| it('trims surrounding whitespace', () => { | ||
| expect(normalizeSearchTagInput(' cat OR dog ')).toBe('cat,dog') | ||
| }) | ||
|
|
||
| it('collapses adjacent/repeated OR separators into a single comma', () => { | ||
| expect(normalizeSearchTagInput('cat OR OR dog')).toBe('cat,dog') | ||
| expect(normalizeSearchTagInput('cat or OR or dog')).toBe('cat,dog') | ||
| expect(normalizeSearchTagInput('cat OR OR OR dog')).toBe('cat,dog') | ||
| }) | ||
|
Comment on lines
+4
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Good test coverage — consider adding edge case tests. The tests thoroughly cover the main scenarios and address the prior review feedback about adjacent OR tokens. Consider adding tests for:
📝 Suggested additional test casesit('handles empty and falsy inputs', () => {
expect(normalizeSearchTagInput('')).toBe('')
expect(normalizeSearchTagInput(null as unknown as string)).toBe('')
expect(normalizeSearchTagInput(undefined as unknown as string)).toBe('')
})
it('handles leading/trailing OR tokens', () => {
// Document current behavior (produces leading/trailing commas)
// or update if the helper is changed to strip them
expect(normalizeSearchTagInput('OR cat')).toBe(',cat')
expect(normalizeSearchTagInput('cat OR')).toBe('cat,')
expect(normalizeSearchTagInput('OR')).toBe(',')
})🤖 Prompt for AI Agents |
||
| }) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Rule-34/App
Length of output: 90
🏁 Script executed:
Repository: Rule-34/App
Length of output: 82
🏁 Script executed:
Repository: Rule-34/App
Length of output: 319
🏁 Script executed:
Repository: Rule-34/App
Length of output: 123
🏁 Script executed:
# Read the test file to see all test cases cat -n test/assets/search-tag-input-helper.test.tsRepository: Rule-34/App
Length of output: 1588
🏁 Script executed:
Repository: Rule-34/App
Length of output: 2896
🏁 Script executed:
# Check the full file to understand the implementation cat -n assets/js/SearchTagInputHelper.tsRepository: Rule-34/App
Length of output: 573
🏁 Script executed:
Repository: Rule-34/App
Length of output: 290
🏁 Script executed:
Repository: Rule-34/App
Length of output: 3033
🏁 Script executed:
Repository: Rule-34/App
Length of output: 177
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 100
🏁 Script executed:
Repository: Rule-34/App
Length of output: 811
🏁 Script executed:
Repository: Rule-34/App
Length of output: 508
🏁 Script executed:
Repository: Rule-34/App
Length of output: 123
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 39
🏁 Script executed:
Repository: Rule-34/App
Length of output: 2044
🏁 Script executed:
Repository: Rule-34/App
Length of output: 1637
🏁 Script executed:
Repository: Rule-34/App
Length of output: 273
🏁 Script executed:
Repository: Rule-34/App
Length of output: 1941
🏁 Script executed:
Repository: Rule-34/App
Length of output: 721
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 863
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 1815
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 175
🏁 Script executed:
Repository: Rule-34/App
Length of output: 785
🏁 Script executed:
Repository: Rule-34/App
Length of output: 397
🏁 Script executed:
Repository: Rule-34/App
Length of output: 920
🏁 Script executed:
Repository: Rule-34/App
Length of output: 480
🏁 Script executed:
Repository: Rule-34/App
Length of output: 1039
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
🏁 Script executed:
Repository: Rule-34/App
Length of output: 37
Add test coverage and fix leading/trailing comma edge case.
The edge cases with leading/trailing
ORtokens are real. Inputs like"OR cat","cat OR", or"OR"produce",cat","cat,", and","respectively. While the existing tests cover trimming, repeated OR collapsing, and space-to-underscore conversion, they don't cover these leading/trailing scenarios.The normalized value is passed directly to downstream API calls without additional sanitization, so these malformed delimiters should be filtered out:
Recommended fix
Add test cases covering the edge scenarios:
normalizeSearchTagInput('OR cat')should return'cat'normalizeSearchTagInput('cat OR')should return'cat'normalizeSearchTagInput('OR')should return''📝 Committable suggestion
🤖 Prompt for AI Agents