Remove UnderscoreSupportingURI.
This commit is contained in:
parent
23da0aa7fb
commit
a92b6318eb
@ -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"
|
||||
|
||||
@ -7,7 +7,7 @@ module Hbc
|
||||
|
||||
def initialize(uri, parameters = {})
|
||||
@parameters = parameters
|
||||
@uri = UnderscoreSupportingURI.parse(uri)
|
||||
@uri = URI(uri)
|
||||
@checkpoint = @parameters[:checkpoint]
|
||||
end
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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]
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user