← Back to PRs

#7395: fix(whatsapp): strip markdown bold/italic from URLs before sending

by lailoo open 2026-02-02 19:36 View on GitHub →
channel: whatsapp-web
## Summary Fixes #7153 When the LLM wraps a URL in markdown formatting like `**https://example.com**`, WhatsApp includes the `**` characters in the tappable URL, breaking the link. ## Solution Strip bold/italic markers (`**`, `*`, `__`, `_`) that immediately surround a URL pattern before sending on WhatsApp. ## Changes - Add `stripMarkdownFromUrls()` function in `src/whatsapp/strip-url-markdown.ts` - Add 11 unit tests covering all markdown patterns - Integrate into `sendMessageWhatsApp()` after markdown table conversion ## Examples | Input | Output | |-------|--------| | `Check **https://example.com**` | `Check https://example.com` | | `Visit *https://foo.bar/path*` | `Visit https://foo.bar/path` | | `See __https://a.com__ and _https://b.com_` | `See https://a.com and https://b.com` | Non-URL bold/italic text is preserved: | Input | Output | |-------|--------| | `This is **bold** text` | `This is **bold** text` | ## Testing - ✅ 11/11 unit tests pass - ✅ Lint passes <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a small WhatsApp-specific text normalization step that strips surrounding markdown emphasis markers (`**`, `*`, `__`, `_`) when they directly wrap a URL, preventing WhatsApp from including the markers in the tappable link. The new helper lives in `src/whatsapp/strip-url-markdown.ts`, has dedicated Vitest coverage, and is applied in `sendMessageWhatsApp()` in `src/web/outbound.ts` after markdown table conversion. <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge; changes are localized and covered by unit tests. - The change is a straightforward pure function plus a single call site. Main remaining risk is correctness of the URL regex across real-world URLs (e.g., parentheses) and ensuring behavior is covered by an integration-level outbound test. - src/whatsapp/strip-url-markdown.ts (URL regex edge cases) <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs