Skip to content
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

fix: revert unintended changes #6118

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function trimTopic(topic: string) {
return (
topic
// fix for gemini
.replace(/^["""*]+|[""*]+$/g, "")
.replace(/[οΌŒγ€‚οΌοΌŸ""""、,.!?*]*$/, "")
.replace(/^["β€œβ€*]+|["β€œβ€*]+$/g, "")
.replace(/[οΌŒγ€‚οΌοΌŸβ€β€œ"、,.!?*]*$/, "")
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codebase verification

Remove unnecessary asterisk character from regex patterns

The trimTopic function's regex patterns include the asterisk character (*), but there's no evidence of it being used in topic text or mentioned in the function's purpose. The patterns should be simplified to:

  1. .replace(/^["""]+|["""]+$/g, "")
  2. .replace(/[οΌŒγ€‚οΌοΌŸ"""、,.!?]*$/, "")
πŸ”— Analysis chain

Review the regex patterns for correctness

The regex patterns have been modified to handle both straight and curly quotes:

  1. ^["""*]+|["""*]+$ - matches one or more quotes or asterisks at start/end
  2. [οΌŒγ€‚οΌοΌŸ"""、,.!?*]*$ - matches zero or more punctuation marks at end

While the patterns are technically correct, a few observations:

  1. The asterisk * character is included in both patterns but isn't mentioned in the comment
  2. The second pattern mixes Chinese/Japanese (οΌŒγ€‚οΌοΌŸγ€) and Latin punctuation marks

Let's verify if these characters are used in the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of asterisk and CJK punctuation in text content
rg -l "[οΌŒγ€‚οΌοΌŸγ€]" --type ts

Length of output: 648


Script:

#!/bin/bash
# Get context around the regex patterns in utils.ts
rg -B 5 -A 5 '\.replace\(/\^\["""' app/utils.ts

# Search for asterisk usage in text content
rg '"[^"]*\*[^"]*"' --type ts

# Look for similar text processing patterns
ast-grep --pattern 'replace(/[^a-z]/g'

Length of output: 980


Script:

#!/bin/bash
# Get broader context around the regex patterns in utils.ts
rg -B 10 -A 10 '\.replace\(/\^\["""' app/utils.ts

Length of output: 51


Script:

#!/bin/bash
# Try different patterns to get the context
rg -B 10 -A 10 'replace\(/\[οΌŒγ€‚οΌοΌŸ"""' app/utils.ts

# Backup search with simpler pattern
rg -B 10 -A 10 '\.replace\(/\[' app/utils.ts

Length of output: 732

);
}

Expand Down
Loading