aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/appcast.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/gpg.rb6
-rw-r--r--Library/Homebrew/cask/lib/hbc/underscore_supporting_uri.rb28
-rw-r--r--Library/Homebrew/cask/lib/hbc/url.rb2
-rw-r--r--Library/Homebrew/test/cask/dsl/appcast_spec.rb2
-rw-r--r--Library/Homebrew/test/cask/underscore_supporting_uri_spec.rb14
7 files changed, 6 insertions, 49 deletions
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index 780acedf5..01a085019 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -25,7 +25,6 @@ require "hbc/scopes"
require "hbc/staged"
require "hbc/system_command"
require "hbc/topological_hash"
-require "hbc/underscore_supporting_uri"
require "hbc/url"
require "hbc/utils"
require "hbc/verify"
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
index fc7e83a20..f984ac088 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb
@@ -7,7 +7,7 @@ module Hbc
def initialize(uri, parameters = {})
@parameters = parameters
- @uri = UnderscoreSupportingURI.parse(uri)
+ @uri = URI(uri)
@checkpoint = @parameters[:checkpoint]
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb b/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb
index b49ebb97c..99b39d43f 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/gpg.rb
@@ -14,11 +14,11 @@ module Hbc
def initialize(signature, parameters = {})
@parameters = parameters
- @signature = UnderscoreSupportingURI.parse(signature)
+ @signature = URI(signature)
parameters.each do |hkey, hvalue|
raise "invalid 'gpg' parameter: '#{hkey.inspect}'" unless VALID_PARAMETERS.include?(hkey)
writer_method = "#{hkey}=".to_sym
- hvalue = UnderscoreSupportingURI.parse(hvalue) if hkey == :key_url
+ hvalue = URI(hvalue) if hkey == :key_url
valid_id?(hvalue) if hkey == :key_id
send(writer_method, hvalue)
end
@@ -35,7 +35,7 @@ module Hbc
end
def to_yaml
- # bug, :key_url value is not represented as an instance of Hbc::UnderscoreSupportingURI
+ # bug, :key_url value is not represented as an instance of URI
[@signature, @parameters].to_yaml
end
diff --git a/Library/Homebrew/cask/lib/hbc/underscore_supporting_uri.rb b/Library/Homebrew/cask/lib/hbc/underscore_supporting_uri.rb
deleted file mode 100644
index 8f8f66f43..000000000
--- a/Library/Homebrew/cask/lib/hbc/underscore_supporting_uri.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require "uri"
-
-module Hbc
- module UnderscoreSupportingURI
- def self.parse(maybe_uri)
- return nil if maybe_uri.nil?
- URI.parse(maybe_uri)
- rescue URI::InvalidURIError => e
- scheme, host, path = simple_parse(maybe_uri)
- raise e unless path && host.include?("_")
- URI.parse(without_host_underscores(scheme, host, path)).tap do |uri|
- uri.instance_variable_set("@host", host)
- end
- end
-
- def self.simple_parse(maybe_uri)
- scheme, host_and_path = maybe_uri.split("://")
- host, path = host_and_path.split("/", 2)
- [scheme, host, path]
- rescue StandardError
- nil
- end
-
- def self.without_host_underscores(scheme, host, path)
- ["#{scheme}:/", host.tr("_", "-"), path].join("/")
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/url.rb b/Library/Homebrew/cask/lib/hbc/url.rb
index 8c652657b..35020c5db 100644
--- a/Library/Homebrew/cask/lib/hbc/url.rb
+++ b/Library/Homebrew/cask/lib/hbc/url.rb
@@ -14,7 +14,7 @@ module Hbc
end
def initialize(uri, options = {})
- @uri = Hbc::UnderscoreSupportingURI.parse(uri)
+ @uri = URI(uri)
@user_agent = options.fetch(:user_agent, :default)
@cookies = options[:cookies]
@referer = options[:referer]
diff --git a/Library/Homebrew/test/cask/dsl/appcast_spec.rb b/Library/Homebrew/test/cask/dsl/appcast_spec.rb
index ccc6a4633..bf703eba2 100644
--- a/Library/Homebrew/test/cask/dsl/appcast_spec.rb
+++ b/Library/Homebrew/test/cask/dsl/appcast_spec.rb
@@ -4,7 +4,7 @@ describe Hbc::DSL::Appcast do
subject { described_class.new(url, params) }
let(:url) { "http://example.com" }
- let(:uri) { Hbc::UnderscoreSupportingURI.parse(url) }
+ let(:uri) { URI(url) }
let(:params) { {} }
describe "#to_s" do
diff --git a/Library/Homebrew/test/cask/underscore_supporting_uri_spec.rb b/Library/Homebrew/test/cask/underscore_supporting_uri_spec.rb
deleted file mode 100644
index 49d3ea63f..000000000
--- a/Library/Homebrew/test/cask/underscore_supporting_uri_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe Hbc::UnderscoreSupportingURI, :cask do
- describe "parse" do
- it "works like normal on normal URLs" do
- uri = Hbc::UnderscoreSupportingURI.parse("http://example.com/TestCask.dmg")
- expect(uri).to eq(URI("http://example.com/TestCask.dmg"))
- end
-
- it "works just fine on URIs with underscores" do
- uri = Hbc::UnderscoreSupportingURI.parse("http://dl_dir.qq.com/qqfile/qq/QQforMac/QQ_V3.0.0.dmg")
- expect(uri.host).to include("_")
- expect(uri.to_s).to eq("http://dl_dir.qq.com/qqfile/qq/QQforMac/QQ_V3.0.0.dmg")
- end
- end
-end