Skip to content

Conversation

@guitavano
Copy link
Contributor

@guitavano guitavano commented Oct 16, 2025

Summary by CodeRabbit

  • Style

    • Minor formatting and whitespace cleanup across utility and action modules; no functional changes.
  • Improvements

    • Updated slug generation to better preserve decimals and separators for price-range strings.
    • Adjusted product listing filter handling for category facets, which may affect how category filters are applied.

@github-actions
Copy link
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.128.14 update
  • 🎉 for Minor 0.129.0 update
  • 🚀 for Major 1.0.0 update

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

Formatting and whitespace edits across several utilities and HubSpot actions, plus a functional change adding price-range detection to vtex/utils/slugify.ts and a behavioral tweak in vtex/loaders/legacy/productListingPage.ts (always passing false to legacyFacetToFilter).

Changes

Cohort / File(s) Summary
Formatting & JSDoc cleanup
google-drive/utils/query.ts, google-drive/utils/types.ts, hubspot/actions/conversations/archiveThread.ts, hubspot/actions/conversations/updateThread.ts
Removed/adjusted blank lines and JSDoc/interface whitespace; no functional changes to logic or exports.
Slugify price-range detection
vtex/utils/slugify.ts
Replaced inline expression with block-bodied slugify implementation and added conditional branch detecting price-range patterns (e.g., de-<num>-a-<num>). Price-range path preserves decimals and applies a tailored set of replacements; non-price path retains original mappings.
Facet handling change
vtex/loaders/legacy/productListingPage.ts
Changed call to legacyFacetToFilter to always pass false (previously passed (name === "Categories")), altering how the Categories facet is processed while leaving other surrounding logic intact.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as slugify(caller)
    participant SL as slugify
    rect #E8F6EF
      Caller->>SL: provide input string
      alt matches price-range (de-<num>-a-<num>)
        SL->>SL: remove commas\nreplace separators with '-' \nreplace special chars\nmap chars, preserve decimals\nlowercase and return
      else non-price
        SL->>SL: apply original replacements\nmap chars\nlowercase and return
      end
    end
Loading
sequenceDiagram
    participant Loader as productListingPage loader
    participant legacy as legacyFacetToFilter
    Loader->>legacy: call legacyFacetToFilter(facet, false)
    Note right of legacy #FFF3CD: Previously the second arg could be (name === "Categories")\nNow always `false`, changing Categories handling
    legacy-->>Loader: return filter
    Loader->>Loader: collect filters and continue processing
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • mcandeia
  • aka-sacci-ccr

Poem

🐰
Soft paws tidy trailing lines away,
Decimal hops stay in the price-range play,
Facets sorted with a subtle flip,
Slugs and queries neat on every tip,
Code nibbles clean — a rabbit's day! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request lacks any description and does not include the required sections from the repository’s template such as the change summary, issue link, Loom video, or demonstration link. Please add a pull request description using the provided template by filling out “What is this Contribution About?”, linking the relevant issue, and including both a Loom video and a demonstration link so reviewers have full context.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly captures the primary update to the slugify function to handle price range patterns without over describing secondary formatting or whitespace adjustments elsewhere in the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tavano/fix-slugify

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
vtex/utils/slugify.ts (3)

12-14: Remove redundant underscore replacement.

Underscore appears in both Line 13's pattern [·/_:] and Line 14's pattern. The first replacement converts underscore to hyphen, making the second occurrence redundant.

Apply this diff:

-      .replace(/,(\d+)/g, ".$1") // Convert comma decimals to dot decimals
-      .replace(/[·/_:]/g, "-")
-      .replace(/[*+~()'"!:@&\[\]`/ %$#?{}|><=_^]/g, "-") // Remove dot from this regex too
+      .replace(/,(\d+)/g, ".$1")
+      .replace(/[·/_:]/g, "-")
+      .replace(/[*+~()'"!:@&\[\]`/ %$#?{}|><=^]/g, "-") // Removed redundant underscore

21-29: Original behavior correctly preserved.

The non-price path maintains the existing logic, which is appropriate for backward compatibility.

Optionally, you could remove the redundant underscore from Line 25's pattern since Line 24 already replaces it.


5-30: Consider adding JSDoc documentation.

The function now handles a special case (price ranges with decimal preservation) that would benefit from documentation explaining the Portuguese "de-X-a-Y" format and the rationale for different handling.

Example:

+/**
+ * Converts a string to a URL-friendly slug.
+ * 
+ * Special handling for Portuguese price ranges (e.g., "de-400-a-799.99"):
+ * - Preserves decimal points in numeric values
+ * - Normalizes comma decimals to dot decimals
+ * 
+ * @param str - The string to slugify
+ * @returns The slugified string
+ * 
+ * @example
+ * slugify("Café São Paulo") // "cafe-sao-paulo"
+ * slugify("de-400-a-799.99") // "de-400-a-799.99"
+ * slugify("de-400-a-799,99") // "de-400-a-799.99"
+ */
 export const slugify = (str: string) => {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1ae949 and 8e5480b.

📒 Files selected for processing (5)
  • google-drive/utils/query.ts (1 hunks)
  • google-drive/utils/types.ts (3 hunks)
  • hubspot/actions/conversations/archiveThread.ts (0 hunks)
  • hubspot/actions/conversations/updateThread.ts (0 hunks)
  • vtex/utils/slugify.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • hubspot/actions/conversations/updateThread.ts
  • hubspot/actions/conversations/archiveThread.ts
🔇 Additional comments (2)
google-drive/utils/types.ts (1)

127-248: LGTM! JSDoc formatting improvements.

The changes add blank lines within JSDoc comments for improved readability. No functional impact.

google-drive/utils/query.ts (1)

3-17: LGTM! JSDoc formatting improvements.

The changes add blank lines within the JSDoc comment for improved readability. No functional impact.

Comment on lines +6 to +8
// 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);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Anchor the regex to prevent false positives.

The current regex uses .test() without anchors, so it matches if the pattern appears anywhere in the string. For example, "product-name-de-400-a-799-other-text" would incorrectly be treated as a price range.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 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);
// 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);
🤖 Prompt for AI Agents
In vtex/utils/slugify.ts around lines 6 to 8, the regex used to detect price
ranges is unanchored and can match substrings anywhere in the input; update the
pattern to anchor it (use ^ and $ or equivalent) so it only matches the entire
string formatted as a price range (e.g., ^de-\d+([,.]?\d+)?-a-\d+([,.]?\d+)?$),
then run tests or sample inputs like "product-de-400-a-799-other" to verify it
no longer yields false positives.

Comment on lines +11 to +18
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();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Comma decimals are corrupted.

The regex at Line 7 accepts both comma and dot as decimal separators ([,.]?), but Line 12 removes all commas. This means price ranges with comma decimals (e.g., "de-400-a-799,99") become "de-400-a-79999" instead of "de-400-a-799.99".

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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();
return str
.replace(/,(\d+)/g, ".$1") // Convert comma decimals to dot decimals
.replace(/[·/_:]/g, "-")
.replace(/[*+~()'"!:@&\[\]`/ %$#?{}|><=_^]/g, "-") // Remove dot from this regex too
.split("")
.map((char) => mapped[char] ?? char)
.join("")
.toLowerCase();
🤖 Prompt for AI Agents
In vtex/utils/slugify.ts around lines 11 to 18, the current chain removes all
commas which corrupts comma-based decimals (e.g. "799,99" -> "79999"); before
removing generic commas, first convert comma decimals to dots by adding a
replacement that turns digit-comma-digit sequences into digit-dot-digit (e.g.
use a regex like /(\d),(\d+)/g -> '$1.$2'), then continue to remove any
remaining stray commas and the other characters as before so "799,99" becomes
"799.99" and then slugified correctly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5480b and c96840c.

📒 Files selected for processing (1)
  • vtex/loaders/legacy/productListingPage.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: ci
vtex/loaders/legacy/productListingPage.ts

[error] 370-371: Deno fmt check failed. Found 1 not formatted file in 2080 files. Run 'deno fmt' to fix formatting.

🔇 Additional comments (1)
vtex/loaders/legacy/productListingPage.ts (1)

391-391: Confirm intentional change to fullPath for Categories facets
legacyFacetToFilter’s 8th argument (fullPath) is now always false—previously it was name === "Categories", enabling full-path handling for Categories facets.
• Is disabling fullPath for Categories intentional?
• How does this relate to the PR’s “fix slugify for price ranges”?
fullPath controls whether the filter uses the entire URL segment hierarchy.

? getFlatCategories(vtexFacets.CategoriesTrees)
: {};


Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const filters = Object.entries({
🧰 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
In vtex/loaders/legacy/productListingPage.ts around line 370, there's an extra
blank line that fails the Deno formatter; remove that blank line so the file has
no consecutive empty lines at that location and re-run the formatter (deno fmt)
to verify formatting passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants