Skip to content

Commit

Permalink
NPM: fix GitHub registry not working when path is specified (#7468)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Jun 23, 2023
1 parent c304cbb commit bcdb78d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
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

0 comments on commit bcdb78d

Please sign in to comment.