Skip to content

Let fetch.Resolver take base URLs and ecosystem aliases - #103

Merged
andrew merged 2 commits into
mainfrom
resolver-base-urls
Oct 19, 2026
Merged

andrew merged 2 commits into
mainfrom
resolver-base-urls

Conversation

@andrew

@andrew andrew commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #80
Closes #98

NewResolver now accepts options, and WithBaseURLs(map[string]string) overrides the host used by the hard-coded fallback patterns in resolveWithoutRegistry for npm, cargo, gem, golang, hex, pub, maven and nuget. Ecosystems left out of the map, or given an empty value, keep the public host. Trailing slashes are trimmed. Existing NewResolver() calls are unchanged.

Base URLs use the same form as the proxy's upstream.* settings (https://static.crates.io/crates for cargo, https://repo1.maven.org/maven2 for maven, https://api.nuget.org for nuget), so the proxy can pass its config straight through and proxy mirror stops ignoring configured upstreams.

The resolver also normalises ecosystem names to PURL types with purl.EcosystemToPURLType in RegisterRegistry, ResolveWithOptions and WithBaseURLs, so rubygems/gem, packagist/composer and go/golang are one ecosystem. That fixes the unsupported ecosystem: rubygems failure in git-pkgs/proxy#415.

I checked the base URLs against git-pkgs/proxy with a local replace: with upstream.npm and upstream.cargo_download pointed at a local server, proxy mirror pkg:npm/lodash@4.17.21 pkg:cargo/serde@1.0.193 fetched both from that server, and proxy serve then returned them with the upstream stopped.

https://claude.ai/code/session_01NxsA75HBjdWQKcdx7FDTDc

Callers that never register a registry can now point the hard-coded
fallback patterns at a mirror with WithBaseURLs.

Claude-Session: https://claude.ai/code/session_01NxsA75HBjdWQKcdx7FDTDc
Copilot AI balanced review requested due to automatic review settings October 18, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Names are normalised to PURL types, so rubygems/gem and packagist/composer
resolve the same way.

Claude-Session: https://claude.ai/code/session_01NxsA75HBjdWQKcdx7FDTDc
@andrew andrew changed the title Let fetch.Resolver take per-ecosystem base URLs Let fetch.Resolver take base URLs and ecosystem aliases Oct 18, 2026
@andrew
andrew merged commit b1bd794 into main Oct 19, 2026
6 checks passed
@andrew
andrew deleted the resolver-base-urls branch October 19, 2026 07:11
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.

fetch.Resolver: accept ecosystem aliases fetch.Resolver: accept per-ecosystem base URLs

2 participants