#7395: fix(whatsapp): strip markdown bold/italic from URLs before sending
channel: whatsapp-web
Cluster:
WhatsApp Enhancements and Fixes
## 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
#13431: feat(whatsapp): add built-in Markdown to WhatsApp format transform
by asklee-klawd · 2026-02-10
85.3%
#10196: fix(whatsapp): sanitize raw mention IDs in outbound messages
by koala73 · 2026-02-06
84.1%
#8052: fix(whatsapp): strip leading whitespace from outbound messages
by FelixFoster · 2026-02-03
83.3%
#9237: Fix: WhatsApp QR code not rendering in chat
by vishaltandale00 · 2026-02-05
81.1%
#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
by kenken64 · 2026-02-13
80.3%
#16147: fix: use a single asterisk to wrap the bold text in whatsapp
by albertominetti · 2026-02-14
80.3%
#4249: fix(telegram): properly nest link tags inside bold/italic formatting
by pradeeppeddineni · 2026-01-29
79.5%
#19590: fix(whatsapp): normalize Brazilian mobile numbers in JID conversion
by qualiobra · 2026-02-18
78.7%
#19303: Fix WhatsApp internal error leakage + cron.run timeout defaults
by koala73 · 2026-02-17
78.6%
#12700: fix(tts): deliver WhatsApp voice as opus bubble instead of MP3 (#12...
by lailoo · 2026-02-09
78.0%