about summary refs log tree commit homepage
path: root/extras
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-12-02 01:47:52 +0000
committerEric Wong <e@80x24.org>2014-12-02 01:55:25 +0000
commit7a552121db4937f00d2b9a8586a475d02a8f833c (patch)
tree1aa8434d5f05aea7c45e45f770df783e36a3ce13 /extras
parentcc30e1172ed4784dc2d3fdc649fcfbe5f54ab6f3 (diff)
downloadyahns-7a552121db4937f00d2b9a8586a475d02a8f833c.tar.gz
We only want to strip one ".gz" suffix to check for the
original, so avoid a needless use of gsub! and use sub!
instead.

While we're at it, note the use of "dup.sub!" (vs plain "sub")
to ensure we only handle files with a .gz suffix.
Diffstat (limited to 'extras')
-rw-r--r--extras/autoindex.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/extras/autoindex.rb b/extras/autoindex.rb
index 2305c3c..d30f000 100644
--- a/extras/autoindex.rb
+++ b/extras/autoindex.rb
@@ -107,7 +107,9 @@ class Autoindex
 
       if ngz_idx
         ngz_idx.each do |name, entry|
-          ngz_path = name.dup.gsub!(/\.gz\z/, '')
+          # n.b: use use dup.sub! to ensure ngz_path is nil
+          # if .gz is not found
+          ngz_path = name.dup.sub!(/\.gz\z/, '')
           ngz_idx.include?(ngz_path) or files << entry
         end
       end