Skip to content

Commit

Permalink
update npm routing
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Nov 4, 2024
1 parent eee1e73 commit 984132f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@
# see: https://github.com/npm/registry/blob/ae49abf1bac0ec1a3f3f1fceea1cca6fe2dc00e1/docs/responses/package-metadata.md
scope module: :npm, constraints: MimeTypeConstraint.new(:json, :npm, raise_on_no_match: true), defaults: { format: :json } do
get ':package', to: 'package_metadata#show', as: :npm_package_metadata, constraints: {
package: /.*/
# see: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#name
package: %r{(?:@([a-z0-9][a-z0-9-]*[a-z0-9])/)?([a-z0-9][a-z0-9._-]*[a-z0-9])}
}
end

# ignore these npm requests entirely for now e.g. POST /-/npm/v1/security/advisories/bulk
scope module: :npm do
match '/-/npm/*wildcard', via: :all, to: -> env { [404, {}, []] }
end
end

concern :v1 do
Expand Down

0 comments on commit 984132f

Please sign in to comment.