-
Notifications
You must be signed in to change notification settings - Fork 21
fix slugify for price ranges #1434
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,3 @@ export default async function archiveThread( | |
| `/conversations/v3/conversations/threads/${threadId}`, | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,4 +151,3 @@ export default async function updateThread( | |
|
|
||
| return response; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,12 +2,29 @@ const mapped = JSON.parse( | |||||||||||||||||||||||||||||||||
| `{"Á":"A","Ä":"A","Â":"A","À":"A","Ã":"A","Å":"A","Č":"C","Ç":"C","Ć":"C","Ď":"D","É":"E","Ě":"E","Ë":"E","È":"E","Ê":"E","Ẽ":"E","Ĕ":"E","Ȇ":"E","Í":"I","Ì":"I","Î":"I","Ï":"I","Ň":"N","Ñ":"N","Ó":"O","Ö":"O","Ò":"O","Ô":"O","Õ":"O","Ø":"O","Ř":"R","Ŕ":"R","Š":"S","Ť":"T","Ú":"U","Ů":"U","Ü":"U","Ù":"U","Û":"U","Ý":"Y","Ÿ":"Y","Ž":"Z","á":"a","ä":"a","â":"a","à":"a","ã":"a","å":"a","č":"c","ç":"c","ć":"c","ď":"d","é":"e","ě":"e","ë":"e","è":"e","ê":"e","ẽ":"e","ĕ":"e","ȇ":"e","í":"i","ì":"i","î":"i","ï":"i","ň":"n","ñ":"n","ó":"o","ö":"o","ò":"o","ô":"o","õ":"o","ø":"o","ð":"o","ř":"r","ŕ":"r","š":"s","ť":"t","ú":"u","ů":"u","ü":"u","ù":"u","û":"u","ý":"y","ÿ":"y","ž":"z","þ":"b","Þ":"B","Đ":"D","đ":"d","ß":"B","Æ":"A","a":"a"}`, | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export const slugify = (str: string) => | ||||||||||||||||||||||||||||||||||
| str | ||||||||||||||||||||||||||||||||||
| export const slugify = (str: string) => { | ||||||||||||||||||||||||||||||||||
| // Check if this looks like a price range (e.g., "de-400-a-799.99") | ||||||||||||||||||||||||||||||||||
| const isPriceRange = /de-\d+([,.]?\d+)?-a-\d+([,.]?\d+)?/.test(str); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+8
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. Anchor the regex to prevent false positives. The current regex uses Apply this diff to anchor the regex: - const isPriceRange = /de-\d+([,.]?\d+)?-a-\d+([,.]?\d+)?/.test(str);
+ const isPriceRange = /^de-\d+([,.]?\d+)?-a-\d+([,.]?\d+)?$/.test(str);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| if (isPriceRange) { | ||||||||||||||||||||||||||||||||||
| // For price ranges, preserve decimal points and only replace other special chars | ||||||||||||||||||||||||||||||||||
| return str | ||||||||||||||||||||||||||||||||||
| .replace(/,/g, "") | ||||||||||||||||||||||||||||||||||
| .replace(/[·/_:]/g, "-") // Remove dot from this regex to preserve decimals | ||||||||||||||||||||||||||||||||||
| .replace(/[*+~()'"!:@&\[\]`/ %$#?{}|><=_^]/g, "-") // Remove dot from this regex too | ||||||||||||||||||||||||||||||||||
| .split("") | ||||||||||||||||||||||||||||||||||
| .map((char) => mapped[char] ?? char) | ||||||||||||||||||||||||||||||||||
| .join("") | ||||||||||||||||||||||||||||||||||
| .toLowerCase(); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+18
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. Critical: Comma decimals are corrupted. The regex at Line 7 accepts both comma and dot as decimal separators ( Apply this diff to convert comma decimals to dots: - return str
- .replace(/,/g, "")
- .replace(/[·/_:]/g, "-") // Remove dot from this regex to preserve decimals
+ return str
+ .replace(/,(\d+)/g, ".$1") // Convert comma decimals to dot decimals
+ .replace(/[·/_:]/g, "-")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Original behavior for non-price strings | ||||||||||||||||||||||||||||||||||
| return str | ||||||||||||||||||||||||||||||||||
| .replace(/,/g, "") | ||||||||||||||||||||||||||||||||||
| .replace(/[·/_,:]/g, "-") | ||||||||||||||||||||||||||||||||||
| .replace(/[*+~.()'"!:@&\[\]`/ %$#?{}|><=_^]/g, "-") | ||||||||||||||||||||||||||||||||||
| .split("") | ||||||||||||||||||||||||||||||||||
| .map((char) => mapped[char] ?? char) | ||||||||||||||||||||||||||||||||||
| .join("") | ||||||||||||||||||||||||||||||||||
| .toLowerCase(); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
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.
Remove extra blank line to fix formatting check.
The Deno formatter detected an extra blank line here that should be removed.
Apply this diff to fix the formatting:
- const filters = Object.entries({📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: ci
[error] 370-371: Deno fmt check failed. Found 1 not formatted file in 2080 files. Run 'deno fmt' to fix formatting.
🤖 Prompt for AI Agents