Fix markdown parser dropping local files whose name starts with "http"#494
Open
Osamaali313 wants to merge 1 commit into
Open
Fix markdown parser dropping local files whose name starts with "http"#494Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
extractReferences skipped any link target starting with "http" to filter
external URLs, but startsWith("http") also matches local files such as
http-client.md, https-setup.md, or httpie.md, so those relative references
were silently dropped from the knowledge graph. Match an actual URL scheme
(scheme://... or protocol-relative //...) instead, so external URLs are still
skipped while local files are kept.
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
MarkdownParser.extractReferencesis meant to extract local file/image references and skip external URLs (per its docstring). It does so with:But
startsWith("http")matches the bare substring, so any local file whose name begins with "http" is silently dropped — e.g.[guide](http-client.md),[notes](https-setup.md),[x](httpie.md). These are relative links that should becomefilereference edges in the knowledge graph but are discarded, producing missing edges.Fix
Match an actual URL scheme instead of the
"http"prefix:This still skips
https://example.com,http://…,ftp://…, and protocol-relative//cdn/…, while keeping local files likehttp-client.md.Testing
Added a case to the
MarkdownParsersuite inparsers.test.ts:Verified standalone with the exact
extractReferencesregex/logic:The existing "extracts file references" and "skips external URLs in references" tests remain satisfied by the fix.