diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index c578c9b8..1786a317 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -49,7 +49,7 @@ module Jekyll # # Returns a Set with the directory paths def new_dirs - new_files.flat_map { |file| parent_dirs(file) }.to_set + new_files.map { |file| parent_dirs(file) }.flatten.to_set end # Private: The list of parent directories of a given file @@ -76,7 +76,7 @@ module Jekyll # # Returns a Set with the directory paths def keep_dirs - site.keep_files.flat_map { |file| parent_dirs(File.join(site.dest, file)) }.to_set + site.keep_files.map { |file| parent_dirs(File.join(site.dest, file)) }.flatten.to_set end # Private: Creates a regular expression from the config's keep_files array diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index f816e165..68b85acb 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -115,7 +115,7 @@ module Jekyll # # Returns the post title def title - data.fetch("title") { titleized_slug } + data.fetch('title') { titleized_slug } end # Turns the post slug into a suitable title diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 8773e018..56173de6 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -46,24 +46,23 @@ module Jekyll # Returns the _unsanitizied_ String URL def generate_url @placeholders.inject(@template) do |result, token| - result.tr(":#{token.first}", self.class.escape_path(token.last)) + break result if result.index(':').nil? + result.gsub(':#{token.first}', self.class.escape_path(token.last)) end end # Returns a sanitized String URL def sanitize_url(in_url) - url = in_url + url = in_url \ # Remove all double slashes - .tr('//', '/') \ - + .gsub(/\/\//, '/') \ # Remove every URL segment that consists solely of dots .split('/').reject{ |part| part =~ /^\.+$/ }.join('/') \ - # Always add a leading slash .gsub(/\A([^\/])/, '/\1') # Append a trailing slash to the URL if the unsanitized URL had one - url << "/" if in_url =~ /\/$/ + url << "/" if in_url[-1].eql?('/') url end