fix(importer): catch inline markdown image URLs + alt laddr URL shapes#110
Merged
Conversation
After PR #109 landed, a sandbox smoke check found 25 codeforphilly.org media URLs still leaking through to bodies. Two root causes: 1. **Inline markdown image syntax inside Markdown items.** Authors wrote `` directly in some posts rather than using the structured Media item path. The Embed-only URL scan never reached them. 2. **Alternate URL shapes** my regex didn't accept: /media/<id> (no trailing slash) /media/open/<id> (legacy "open media" namespace) /sitedata/<id> (older asset namespace) Fix: rename `rewriteEmbedHtml` → `rewriteLaddrMediaUrls`, broaden the regex to accept the four observed URL shapes, and apply it as a final pass over the **assembled body** (after items have been joined). That catches Markdown-item inline image references the per-item code path can't reach. Per-item Embed rewriting still happens — same regex, same dedup map — because some Embeds reference media that doesn't appear elsewhere (YouTube thumbs etc.) and we want to capture them too. Two new tests cover the inline-markdown case and the alt URL shapes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sandbox smoke check after PR #109 found 25 `codeforphilly.org/...` media URLs still leaking into blog bodies. Two root causes:
Fix: broaden the regex to the four observed URL shapes, and apply it as a final pass over the assembled body (after items are joined). Catches Markdown-item inline references the per-item path can't reach. The function gets renamed `rewriteEmbedHtml` → `rewriteLaddrMediaUrls` since it now applies beyond embeds.
Test plan
🤖 Generated with Claude Code