Skip to content

fix: primary locale url normalization#1219

Merged
jwartofsky-yext merged 4 commits into
mainfrom
fixURLNormalization
May 19, 2026
Merged

fix: primary locale url normalization#1219
jwartofsky-yext merged 4 commits into
mainfrom
fixURLNormalization

Conversation

@jwartofsky-yext
Copy link
Copy Markdown
Contributor

primaryLocales were not getting normalized, which led to a mismatch where "en-GB" in the locale and "en_gb" in the primaryLocale would be seen as different and the locale would be pre-prended.

primaryLocales were not getting normalized, which led to a mismatch
where "en-GB" in the locale and "en_gb" in the primaryLocale would
be seen as different and the locale would be pre-prended.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cefbabda-335f-483f-8e38-cbe673ecf21a

📥 Commits

Reviewing files that changed from the base of the PR and between 5525f4e and 0d94b31.

📒 Files selected for processing (6)
  • packages/visual-editor/src/utils/normalizeLocale.test.ts
  • packages/visual-editor/src/utils/normalizeLocale.ts
  • packages/visual-editor/src/utils/urls/legacyResolveUrlTemplate.test.ts
  • packages/visual-editor/src/utils/urls/legacyResolveUrlTemplate.ts
  • packages/visual-editor/src/utils/urls/resolveUrlFromPathInfo.test.ts
  • packages/visual-editor/src/utils/urls/resolveUrlFromPathInfo.ts

Walkthrough

This PR extends locale field normalization to include primaryLocale and applies normalized locale comparison across two URL resolution utilities. The normalizeLocalesInObject function is updated to normalize both locale and primaryLocale fields into BCP-47 format. Two URL resolution functions—legacyResolveUrlTemplate and resolveUrlFromPathInfo—now normalize locale values before comparing them to determine URL prefixing and primary locale status, ensuring consistent behavior when locale strings differ in formatting (e.g., en_gb vs en-GB).

Sequence Diagram

See the diagrams embedded in the review stack layers above.

Possibly related PRs

  • yext/visual-editor#1060: Updates legacy URL resolution to handle primaryLocale and normalized locale comparisons in legacyResolveUrlTemplate via the same code path and test patterns.
  • yext/visual-editor#998: Refactors URL resolution for primaryLocale handling, introducing the same functions that this PR now enhances with normalized locale comparison.
  • yext/visual-editor#992: Adds normalizeLocalesInObject consumption in stream document processing; this PR extends the normalization utility to cover primaryLocale fields.

Suggested labels

create-dev-release

Suggested reviewers

  • benlife5
  • mkilpatrick
  • asanehisa
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: primary locale url normalization' directly describes the main change: normalizing primaryLocale values to fix URL construction issues.
Description check ✅ Passed The description clearly explains the problem (primaryLocales not being normalized causing locale format mismatches) and the solution, directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fixURLNormalization

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@jwartofsky-yext jwartofsky-yext self-assigned this May 19, 2026
@jwartofsky-yext jwartofsky-yext marked this pull request as ready for review May 19, 2026 14:45
@jwartofsky-yext jwartofsky-yext requested a review from asanehisa May 19, 2026 14:55
@jwartofsky-yext jwartofsky-yext merged commit f1c1465 into main May 19, 2026
17 checks passed
@jwartofsky-yext jwartofsky-yext deleted the fixURLNormalization branch May 19, 2026 14:57
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.

3 participants