Skip to content

Commit

Permalink
Merge pull request #54 from librariesio/mellisio/nil-safe-valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Ellis authored Mar 19, 2020
2 parents fedc17c + 24cc479 commit 229865e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/spdx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def self.licenses
end

def self.valid_spdx?(spdx_string)
return false unless spdx_string.is_a?(String)

SpdxParser.parse(spdx_string)
true
rescue SpdxGrammar::SpdxParseError
Expand Down
2 changes: 1 addition & 1 deletion lib/spdx/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Spdx
VERSION = "2.0.0"
VERSION = "2.0.1"
end
1 change: 1 addition & 0 deletions spec/spdx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
expect(Spdx.valid_spdx?("AND AND")).to be false
expect(Spdx.valid_spdx?("MIT OR MIT AND OR")).to be false
expect(Spdx.valid_spdx?("MIT OR FAKEYLICENSE")).to be false
expect(Spdx.valid_spdx?(nil)).to be false
end
it "returns true for valid spdx" do
expect(Spdx.valid_spdx?("(MIT OR MPL-2.0)")).to be true
Expand Down

0 comments on commit 229865e

Please sign in to comment.