version: fix GitHub releases URLs parsing

The current code doesn't work with releases that have more than one
digit in the third group, i.e.:

  .../releases/download/1.2.3/...  works
  .../releases/download/1.2.34/... doesn't work

Closes Homebrew/homebrew#49255.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2016-02-17 12:26:45 +01:00
parent 270f601050
commit 4c5aee7a56
2 changed files with 3 additions and 1 deletions

View File

@ -316,6 +316,7 @@ class VersionParsingTests < Homebrew::TestCase
def test_jenkins_version_style
assert_version_detected "1.486", "http://mirrors.jenkins-ci.org/war/1.486/jenkins.war"
assert_version_detected "0.10.11", "https://github.com/hechoendrupal/DrupalConsole/releases/download/0.10.11/drupal.phar"
end
def test_apache_version_style

View File

@ -368,7 +368,8 @@ class Version
return m.captures.first unless m.nil?
# e.g. http://mirrors.jenkins-ci.org/war/1.486/jenkins.war
m = /\/(\d\.\d+(\.\d)?)\//.match(spec_s)
# e.g. https://github.com/foo/bar/releases/download/0.10.11/bar.phar
m = /\/(\d\.\d+(\.\d+)?)\//.match(spec_s)
return m.captures.first unless m.nil?
# e.g. http://www.ijg.org/files/jpegsrc.v8d.tar.gz