Skip to content

fix: use location.String() instead of location.Path for origin file tracking#1145

Merged
fenollp merged 1 commit intogetkin:masterfrom
oasdiff:fix/location-string-for-origin-url
Apr 8, 2026
Merged

fix: use location.String() instead of location.Path for origin file tracking#1145
fenollp merged 1 commit intogetkin:masterfrom
oasdiff:fix/location-string-for-origin-url

Conversation

@reuvenharrison
Copy link
Copy Markdown
Contributor

Problem

When a spec is loaded from a URL (e.g. https://raw.githubusercontent.com/owner/repo/sha/schemas/pet.yaml), location.Path strips the scheme and host, leaving only /owner/repo/sha/schemas/pet.yaml. This means origin.Key.File in $ref-referenced files contains an incomplete path instead of the full URL.

Fix

Use location.String() instead of location.Path. For URL locations this preserves the full URL; for local file paths String() and Path are equivalent so there is no behaviour change for local loads.

Impact

Consumers that use origin.Key.File to generate links (e.g. linking to a specific line in a GitHub file) receive the complete URL, not a truncated path.

…racking

location.Path strips the scheme and host for full URLs, leaving only
the path component. For example, for a $ref loaded from
https://raw.githubusercontent.com/owner/repo/sha/schemas/pet.yaml,
location.Path gives /owner/repo/sha/schemas/pet.yaml — missing the host.

Using location.String() preserves the full URL so that origin.Key.File
in $ref-referenced files contains the complete URL, enabling consumers
(e.g. the oasdiff review UI) to build correct clickable links to the
exact file and line on GitHub.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fenollp fenollp merged commit a54fb71 into getkin:master Apr 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants