lib/review/epubmaker/producer.rb in review-5.3.0 vs lib/review/epubmaker/producer.rb in review-5.4.0
- old
+ new
@@ -87,12 +87,12 @@
allow_exts ||= @config['image_ext']
Dir.foreach(path) do |f|
next if f.start_with?('.')
- if f =~ /\.(#{allow_exts.join('|')})\Z/i
- path.chop! if path =~ %r{/\Z}
+ if /\.(#{allow_exts.join('|')})\Z/i.match?(f)
+ path.chop! if %r{/\Z}.match?(path)
if base.nil?
@contents.push(ReVIEW::EPUBMaker::Content.new(file: "#{path}/#{f}"))
else
@contents.push(ReVIEW::EPUBMaker::Content.new(file: "#{path.sub(base + '/', '')}/#{f}"))
end
@@ -113,10 +113,10 @@
current = Dir.pwd
base_dir ||= current
# use Dir to solve a path for Windows (see #1011)
new_tmpdir = Dir[File.join(tmpdir.nil? ? Dir.mktmpdir : tmpdir)][0]
- if epubfile !~ %r{\A/}
+ unless epubfile.start_with?('/')
epubfile = "#{current}/#{epubfile}"
end
# FIXME: error check
File.unlink(epubfile) if File.exist?(epubfile)