From 7a552121db4937f00d2b9a8586a475d02a8f833c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 2 Dec 2014 01:47:52 +0000 Subject: extras/autoindex: simplify checking non-.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. --- extras/autoindex.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-24-ge0c7