diff --git a/ruby_event_store-browser/lib/ruby_event_store/browser/gem_source.rb b/ruby_event_store-browser/lib/ruby_event_store/browser/gem_source.rb index ca05a29e9e..d6177be34f 100644 --- a/ruby_event_store-browser/lib/ruby_event_store/browser/gem_source.rb +++ b/ruby_event_store-browser/lib/ruby_event_store/browser/gem_source.rb @@ -9,7 +9,7 @@ def initialize(load_path) @path = load_path .select { |entry| String === entry } - .find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d\.\d\.\d)?/lib\z} } + .find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z} } end def version @@ -21,7 +21,7 @@ def version end def from_rubygems? - path.match? %r{/gems/ruby_event_store-browser-\d\.\d\.\d/lib\z} + path.match? %r{/gems/ruby_event_store-browser-\d+\.\d+\.\d+/lib\z} end def from_git? diff --git a/ruby_event_store-browser/spec/gem_source_spec.rb b/ruby_event_store-browser/spec/gem_source_spec.rb index e387714d1e..05b4cc6b0b 100644 --- a/ruby_event_store-browser/spec/gem_source_spec.rb +++ b/ruby_event_store-browser/spec/gem_source_spec.rb @@ -37,6 +37,14 @@ module Browser expect(source).to be_from_git end + specify "don't crash on two–digit number in version string" do + path = "/Users/mostlyobvious/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/ruby_event_store-browser-#{RubyEventStore::VERSION}/lib" + source = GemSource.new([random_unrelated_path, path]) + + expect(source.version).to eq(RubyEventStore::VERSION) + expect(source).not_to be_from_git + end + def random_unrelated_path "/kaka/dudu" end