Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM: fix GitHub registry not working when path is specified #7468

Merged
merged 4 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm_and_yarn/lib/dependabot/npm_and_yarn/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def url_for_relevant_cred(resolved_url)
else
URI("https://#{details['registry']}")
end
resolved_url_host == uri.host
resolved_url_host == uri.host && resolved_url.include?(details["registry"])
end

return unless credential_matching_url
Expand Down
25 changes: 25 additions & 0 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,31 @@
}]
)
end

context "with a credential that matches the hostname, but not the path" do
let(:credentials) do
[{
"type" => "npm_registry",
"registry" => "npm.pkg.github.com/dependabot",
"username" => "x-access-token",
"password" => "token"
}]
end

its(:requirements) do
is_expected.to eq(
[{
requirement: "^2.0.1",
file: "package.json",
groups: ["devDependencies"],
source: {
type: "registry",
url: "https://npm.pkg.github.com"
}
}]
)
end
end
end

describe "the scoped gitlab dependency" do
Expand Down
Loading