diff --git a/Library/Homebrew/cask/lib/hbc/container/gzip.rb b/Library/Homebrew/cask/lib/hbc/container/gzip.rb
index 1d2cc1f3714cf431695cf2cee198b1adffddadd3..1615781620367fcebeececb3729faabe78b552f7 100644
--- a/Library/Homebrew/cask/lib/hbc/container/gzip.rb
+++ b/Library/Homebrew/cask/lib/hbc/container/gzip.rb
@@ -10,7 +10,7 @@ class Hbc::Container::Gzip < Hbc::Container::Base
   def extract
     Dir.mktmpdir do |unpack_dir|
       @command.run!("/usr/bin/ditto",  args: ["--", @path, unpack_dir])
-      @command.run!("/usr/bin/gunzip", args: ["--quiet", "--", Pathname.new(unpack_dir).join(@path.basename)])
+      @command.run!("/usr/bin/gunzip", args: ["--quiet", "--name", "--", Pathname.new(unpack_dir).join(@path.basename)])
 
       extract_nested_inside(unpack_dir)
     end
diff --git a/Library/Homebrew/cask/lib/hbc/extend.rb b/Library/Homebrew/cask/lib/hbc/extend.rb
index 629c53468e6d5b6a11458fe6e81c9e19e90a510a..e836b6bc8e139f27a6b0ac1399785d2858419b6e 100644
--- a/Library/Homebrew/cask/lib/hbc/extend.rb
+++ b/Library/Homebrew/cask/lib/hbc/extend.rb
@@ -2,5 +2,5 @@
 require "hbc/extend/hash"
 require "hbc/extend/io"
 require "hbc/extend/optparse"
-require "hbc/extend/pathname"
+require "extend/pathname"
 require "hbc/extend/string"
diff --git a/Library/Homebrew/cask/lib/hbc/extend/pathname.rb b/Library/Homebrew/cask/lib/hbc/extend/pathname.rb
deleted file mode 100644
index 598a99cd2d6bd7fd0f048eb25a444d5c8206b526..0000000000000000000000000000000000000000
--- a/Library/Homebrew/cask/lib/hbc/extend/pathname.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "pathname"
-
-class Pathname
-  # extended to support common double extensions
-  def extname(path = to_s)
-    %r{(\.(dmg|tar|cpio|pax)\.(gz|bz2|lz|xz|Z|zip))$} =~ path
-    return Regexp.last_match(1) if Regexp.last_match(1)
-    File.extname(path)
-  end
-
-  # https://bugs.ruby-lang.org/issues/9915
-  if RUBY_VERSION == "2.0.0"
-    prepend Module.new {
-      def inspect
-        super.force_encoding(@path.encoding)
-      end
-    }
-  end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 8e55b8a9920199a80e8e75cfa053b5d88fc1d559..8f43884a3d718e2b18da05246c90506ec991bbaf 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -1,6 +1,5 @@
 require "rubygems"
 
-require "extend/pathname"
 require "hbc/cask_dependencies"
 require "hbc/staged"
 require "hbc/verify"
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index a826cfcf01a7a8b48ec07b8dd49f94a6fa1e1fb1..d197db98355678e2fd9b80a400137633788b1a70 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -13,7 +13,6 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__))
 $LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
 
 require "global"
-require "extend/pathname"
 
 # add Homebrew-Cask to load path
 $LOAD_PATH.push(project_root.join("lib").to_s)
diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb
index 34ea2e32106ff6b893e7b7ef0d5806a6c4921ea2..2275c30801dc2059c2f517fd2271bc51b349304b 100644
--- a/Library/Homebrew/cask/test/cask/installer_test.rb
+++ b/Library/Homebrew/cask/test/cask/installer_test.rb
@@ -154,7 +154,7 @@ describe Hbc::Installer do
 
       dest_path = Hbc.caskroom.join("container-gzip", asset.version)
       dest_path.must_be :directory?
-      file = Hbc.appdir.join("container-gzip--#{asset.version}")
+      file = Hbc.appdir.join("container")
       file.must_be :file?
     end
 
diff --git a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
index 0a5c64ba93de0db5603e9803ce0842c4bddd5d1e..eac74a04c11d85d2fa7c5578ebbbb2552cb95eee 100644
--- a/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
+++ b/Library/Homebrew/cask/test/support/Casks/container-gzip.rb
@@ -5,5 +5,5 @@ test_cask 'container-gzip' do
   url TestHelper.local_binary_url('container.gz')
   homepage 'https://example.com/container-gzip'
 
-  app 'container-gzip--1.2.3'
+  app 'container'
 end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index fdbd8af0e2c3e99dcc6c57c6099f769dae0cf6b3..24c979535165b97f97103e656dc87d15b0296962 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -14,7 +14,6 @@ tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homeb
 $LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
 
 require "global"
-require "extend/pathname"
 
 # add Homebrew-Cask to load path
 $LOAD_PATH.push(project_root.join("lib").to_s)
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index c9cc9d3f3c6df02ab6a96b7606be585368c7ac34..324f72d1e457cef75e93fc09ee9eac3b1f7f6ca8 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -216,10 +216,10 @@ class Pathname
 
   # extended to support common double extensions
   def extname(path = to_s)
-    BOTTLE_EXTNAME_RX.match(path)
-    return $1 if $1
-    /(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/.match(path)
-    return $1 if $1
+    bottle_ext = path[BOTTLE_EXTNAME_RX, 1]
+    return bottle_ext if bottle_ext
+    archive_ext = path[/(\.(tar|cpio|pax)\.(gz|bz2|lz|xz|Z))$/, 1]
+    return archive_ext if archive_ext
     File.extname(path)
   end
 
@@ -445,8 +445,8 @@ class Pathname
     end
   end
 
+  # https://bugs.ruby-lang.org/issues/9915
   if RUBY_VERSION == "2.0.0"
-    # https://bugs.ruby-lang.org/issues/9915
     prepend Module.new {
       def inspect
         super.force_encoding(@path.encoding)