From 156dc09dfdc70eeb5bb336e54a084956e308a8e8 Mon Sep 17 00:00:00 2001 From: Daniel Birnstiel Date: Thu, 24 Oct 2019 15:58:40 +0200 Subject: [PATCH] Add slash to search pattern if missing --- lib/jekyll-webp/webpGenerator.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-webp/webpGenerator.rb b/lib/jekyll-webp/webpGenerator.rb index c17c432..8915a72 100644 --- a/lib/jekyll-webp/webpGenerator.rb +++ b/lib/jekyll-webp/webpGenerator.rb @@ -50,9 +50,15 @@ def generate(site) imgdir_destination = File.join(site.dest, imgdir) FileUtils::mkdir_p(imgdir_destination) Jekyll.logger.info "WebP:","Processing #{imgdir_source}" - + + # append a / if missing + imgdir_search_prefix = imgdir_source + if !imgdir_source.end_with?("/") then + imgdir_search_prefix = imgdir_source + "/" + end + # handle only jpg, jpeg, png and gif - for imgfile in Dir[imgdir_source + "**/*.*"] + for imgfile in Dir[imgdir_search_prefix + "**/*.*"] imgfile_relative_path = File.dirname(imgfile.sub(imgdir_source, "")) # Skip empty stuff