-
Notifications
You must be signed in to change notification settings - Fork 0
fix: router keyword matching now uses whole words, not substrings #36
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
Merged
+37
−6
Merged
Changes from all commits
Commits
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
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
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Amayyas/Chorus
Length of output: 2335
🏁 Script executed:
Repository: Amayyas/Chorus
Length of output: 710
🌐 Web query:
Ruby Regexp /w/ Unicode property \p{Word} documentation💡 Result:
In Ruby regular expressions, \p{Word} is a Unicode property that matches characters defined as word characters according to Unicode standards [1][2]. As of recent Ruby versions, \p{Word} (and the equivalent POSIX-style bracket expression [[:word:]]) matches a character if it belongs to one of the following Unicode categories or has one of the specified Unicode properties [1][2]: Unicode Categories: - Mark (M) [2] - Decimal Number (Nd) [2] - Connector Punctuation (Pc) [2] Unicode Properties: - Alpha (Alphabetic characters) [2] - Join_Control (specifically U+200C and U+200D) [2] Documentation Note: Historically, documentation for \p{Word} was less precise or incomplete regarding the specific Unicode categories and properties included [3][2][4]. Recent updates (e.g., in Ruby 3.3+) have aligned the documentation with current implementations and Unicode Technical Standard
#18, which defines word characters to include alphabetic values, decimal numbers, and join control characters [2][5]. Be aware that bugs or inconsistencies between the documented behavior and the actual implementation of the underlying Unicode character database can occasionally occur across different Ruby versions [3][4]. Comparison with \w: - \w: In Ruby, \w is typically equivalent to [a-zA-Z0-9_] (when not using the /u flag for full Unicode support or when relying on standard ASCII behavior), though its exact behavior can vary depending on the regex engine's configuration and the version of Ruby [6]. - \p{Word}: Unlike \w, \p{Word} is specifically designed for Unicode-aware matching, providing a much broader set of characters that conform to global linguistic standards for what constitutes a word character [1][6].Citations:
🌐 Web query:
site:ruby-doc.org/core Regexp \w Unicode \p{Word}💡 Result:
In regular expression engines, the
\wtoken and\p{Word}property serve different purposes regarding character matching, particularly concerning Unicode support [1][2]. \w (Word Character) The\wshorthand character class typically matches a limited set of ASCII characters. In most standard regex implementations—including Ruby's—it is equivalent to the character set [a-zA-Z0-9_] [1][3]. While some modern regex engines (such as those in PCRE or certain language-specific implementations) may be configured to treat\was Unicode-aware, it is historically and primarily defined as matching ASCII letters, digits, and underscores [1][4]. \p{Word} (Unicode Property) The\p{Word}construct is a Unicode property escape [1][2]. It matches any character that is considered a "word" character according to the Unicode standard [1][4]. This is significantly broader than\wbecause it includes characters from various scripts, symbols, and marks [1][3]. Specifically, it matches any character belonging to the following Unicode General Categories [1][2]: - Letter (L) - Mark (M) - Number (N) - Connector_Punctuation (Pc) While\wis useful for matching technical identifiers constrained to ASCII,\p{Word}is the correct choice for internationalized applications requiring support for a wide range of global languages and character sets [1][4].Citations:
🏁 Script executed:
Repository: Amayyas/Chorus
Length of output: 777
Make tokenization Unicode-aware.
Ruby’s
\wtokenizesclasséas["class", "mean"], causing accented words to still match:coderkeywords. Use a Unicode word property such as/\p{Word}+/and add a regression case for Unicode input.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents