fix(viewer): decode percent-encoded link targets in _extract_links - #400
Open
Sayantan181222 wants to merge 1 commit into
Open
Sayantan181222 wants to merge 1 commit into
Sayantan181222 wants to merge 1 commit into
Conversation
Markdown tools write links to files with spaces using percent-encoding e.g. gross%20margin.md. Path resolution was done on the raw encoded string which never matches the real filename, so all such links were silently dropped producing graphs with 0 edges. Fix: call urllib.parse.unquote() on the link target before resolving the filesystem path. Fixes GoogleCloudPlatform#200
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.
Problem
Bundles with spaces in filenames render with 0 edges in the visualizer.
When a markdown link points to a file with a space in its name, the link
target is percent-encoded e.g.
../metrics/gross%20margin.md. The_extract_linksfunction passed this raw encoded string directly toPathfor filesystem resolution. Since the real file is namedgross margin.md(notgross%20margin.md), the path lookup silentlyfailed and the link was dropped. As a result
_build_graphsaw nomatching concept id and drew no edges.
Fix
Call
urllib.parse.unquote()on the raw link target before resolvingit as a filesystem path. One-line change in
_extract_links.Test
Added
test_percent_encoded_links_produce_edgesintest_viewer.pywhich creates a bundle with a space in one filename, links to it using
%20encoding from another concept, and asserts the edge appears inthe graph output. All 8 tests pass.
Fixes #200