From 823d6a8a7d272aa8ecf288d89bcb44e85c8f80db Mon Sep 17 00:00:00 2001 From: Anthony Scalisi Date: Mon, 12 Dec 2016 15:02:41 -0800 Subject: [PATCH] handle case where version starts with a 'v' prefix --- lib/semverse/version.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/semverse/version.rb b/lib/semverse/version.rb index 99ac707..d70b218 100644 --- a/lib/semverse/version.rb +++ b/lib/semverse/version.rb @@ -17,13 +17,13 @@ def coerce(object) # @return [Array] def split(version_string) case version_string.to_s - when /^(\d+)\.(\d+)\.(\d+)(-([0-9a-z\-\.]+))?(\+([0-9a-z\-\.]+))?$/i + when /^v?(\d+)\.(\d+)\.(\d+)(-([0-9a-z\-\.]+))?(\+([0-9a-z\-\.]+))?$/i [ $1.to_i, $2.to_i, $3.to_i, $5, $7 ] - when /^(\d+)\.(\d+)\.(\d+)?$/ + when /^v?(\d+)\.(\d+)\.(\d+)?$/ [ $1.to_i, $2.to_i, $3.to_i ] - when /^(\d+)\.(\d+)?$/ + when /^v?(\d+)\.(\d+)?$/ [ $1.to_i, $2.to_i, 0 ] - when /^(\d+)$/ + when /^v?(\d+)$/ [ $1.to_i, 0, 0 ] else raise InvalidVersionFormat.new(version_string)