Skip to content

fix(routing): New South Wales is Australia, Índia and U.S. are found, beber isn't a baby - #82

Merged
rferrari merged 1 commit into
mainfrom
fix/emergency-pt-matching
Oct 10, 2026
Merged

rferrari merged 1 commit into
mainfrom
fix/emergency-pt-matching

Conversation

@rferrari

@rferrari rferrari commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Four matching bugs in the offline emergency-number table and the Portuguese search terms. CodeRabbit found them on the native app's Kotlin port, which copies these rules, so the TS is fixed here and the Kotlin on fullnative-dev (749215b) with the same regexes.

Input Before After
"Emergency numbers in New South Wales, Australia?" United Kingdom 999 (from "Wales") Australia 000
"Emergency numbers in New South Wales?" United Kingdom 999 Australia 000
"Números de emergência na Índia" nothing (JS \b is ASCII-only, no boundary before "Í") Índia 112
"Emergency number for the U.S.?" nothing (\b after the last dot needs a letter) United States 911
"Quanta água devo beber por dia?" tagged child ("bebê" matched as a prefix of "beber") not tagged

"Wales" alone still gives the UK, and "Indiana" gives nothing.

Tests: 7 new cases in emergencyNumbers.test.ts and ptQuery.test.ts. npm test 1177/1177, typecheck clean. CodeRabbit (cr review --base main): no findings.

Summary by CodeRabbit

  • Bug Fixes
    • Improved emergency-number matching for New South Wales, U.S. and U.S.A. queries, and accented or unaccented India queries, while avoiding false matches such as Indiana.
    • Improved Portuguese search matching so “bebê” and “bebês” can find child-related information without treating “beber” as a match; water-safety questions also return relevant search terms.

… beber isn't a baby

- 'Wales' inside 'New South Wales' gave the UK's 999 for a question naming
  Australia; 'New South Wales' now names Australia.
- 'Índia': JavaScript's \b is ASCII-only, so no boundary before 'Í'; matched with
  a letter lookbehind instead.
- 'U.S.' before '?' or at the end: \b after the last dot needed a word character.
- PT 'bebê' as a prefix matched 'beber' and 'bebendo', tagging drinking-water
  questions as 'child'.
Found by CodeRabbit on the Kotlin port, which copies these rules.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 24f81544-4b59-436f-aa80-02eb9ac27379


📥 Commits

Reviewing files that changed from the base of the PR and between 9df9523 and 7913c21.



📒 Files selected for processing (4)
  • src/routing/emergencyNumbers.test.ts
  • src/routing/emergencyNumbers.ts
  • src/routing/ptQuery.test.ts
  • src/routing/ptQuery.ts


Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

Country matching now distinguishes several country names and aliases. Portuguese child-term matching no longer matches the start of longer words. Tests cover the updated query cases.

Changes

Emergency-number country matching

Layer / File(s) Summary
Country matching rules and query coverage
src/routing/emergencyNumbers.ts, src/routing/emergencyNumbers.test.ts
Country-name matching and tests cover Wales, New South Wales, India, U.S., and U.S.A. queries.

Portuguese query term matching

Layer / File(s) Summary
Portuguese child-term matching and query coverage
src/routing/ptQuery.ts, src/routing/ptQuery.test.ts
The child-term pattern rejects matches inside longer words. Tests cover accented and unaccented forms and safe-water search terms.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: r4topunk



Merge Risk: ⚪ Minimal · up to 7913c

The change fixes four country-name and Portuguese term matching bugs and adds tests for them. No merge-blocking risk was identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main routing fixes: New South Wales matching Australia, India and U.S. recognition, and preventing beber from matching bebê.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@rferrari
rferrari merged commit f671379 into main Oct 10, 2026
2 checks passed
@rferrari
rferrari deleted the fix/emergency-pt-matching branch October 10, 2026 05:27
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.

1 participant