Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sbom/package_url.rb')
-rw-r--r--lib/sbom/package_url.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/sbom/package_url.rb b/lib/sbom/package_url.rb
index 3b545ebebf2..d8f4e876b82 100644
--- a/lib/sbom/package_url.rb
+++ b/lib/sbom/package_url.rb
@@ -44,7 +44,7 @@ module Sbom
class PackageUrl
# Raised when attempting to parse an invalid package URL string.
# @see #parse
- InvalidPackageURL = Class.new(ArgumentError)
+ InvalidPackageUrl = Class.new(ArgumentError)
# The URL scheme, which has a constant value of `"pkg"`.
def scheme
@@ -79,20 +79,19 @@ module Sbom
# @param qualifiers [Hash] Extra qualifying data for a package, specific to the type of package.
# @param subpath [String] An extra subpath within a package, relative to the package root.
def initialize(type:, name:, namespace: nil, version: nil, qualifiers: nil, subpath: nil)
- raise ArgumentError, 'type is required' unless type.present?
- raise ArgumentError, 'name is required' unless name.present?
-
- @type = type.downcase
+ @type = type&.downcase
@namespace = namespace
@name = name
@version = version
@qualifiers = qualifiers
@subpath = subpath
+
+ ArgumentValidator.new(self).validate!
end
# Creates a new PackageUrl from a string.
# @param [String] string The package URL string.
- # @raise [InvalidPackageURL] If the string is not a valid package URL.
+ # @raise [InvalidPackageUrl] If the string is not a valid package URL.
# @return [PackageUrl]
def self.parse(string)
Decoder.new(string).decode!