Improve pull request URL regexp

- use a regexp literal and avoid escaping forward slashes
 - escape the period in "github.com"
 - match only hex characters in the commit part
 - allow hyphen in usernames and repo names, matching what we allow for
   tap names
 - avoid unnecessary capture
This commit is contained in:
Jack Nagel 2014-07-19 20:25:16 -05:00
parent efcfbcc98b
commit 26b8c5a27d
2 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ ARGV.named.each do |arg|
end
url = url_match[0]
issue = url_match[4]
issue = url_match[3]
end
if tap_name = tap(url)

View File

@ -98,7 +98,7 @@ module Homebrew
alias_method :failed?, :failed
end
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = 'https:\/\/github.com\/(\w+)\/homebrew(-\w+)?\/(pull\/(\d+)|commit\/\w{4,40})'
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/homebrew(-[\w-]+)?/(?:pull/(\d+)|commit/\h{4,40})]
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']