Merge pull request #3516 from jekyll/end-with
Use String#end_with?("/") instead of regexp
This commit is contained in:
commit
50a4b2824b
1
Gemfile
1
Gemfile
|
@ -32,6 +32,7 @@ gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
|
||||||
if ENV['BENCHMARK']
|
if ENV['BENCHMARK']
|
||||||
gem 'rbtrace'
|
gem 'rbtrace'
|
||||||
gem 'stackprof'
|
gem 'stackprof'
|
||||||
|
gem 'benchmark-ips'
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV['PROOF']
|
if ENV['PROOF']
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'benchmark/ips'
|
||||||
|
|
||||||
|
Benchmark.ips do |x|
|
||||||
|
path_without_ending_slash = '/some/very/very/long/path/to/a/file/i/like'
|
||||||
|
x.report('no slash regexp') { path_without_ending_slash =~ /\/$/ }
|
||||||
|
x.report('no slash end_with?') { path_without_ending_slash.end_with?("/") }
|
||||||
|
end
|
||||||
|
|
||||||
|
Benchmark.ips do |x|
|
||||||
|
path_with_ending_slash = '/some/very/very/long/path/to/a/file/i/like/'
|
||||||
|
x.report('slash regexp') { path_with_ending_slash =~ /\/$/ }
|
||||||
|
x.report('slash end_with?') { path_with_ending_slash.end_with?("/") }
|
||||||
|
end
|
|
@ -163,7 +163,7 @@ module Jekyll
|
||||||
def destination(base_directory)
|
def destination(base_directory)
|
||||||
dest = site.in_dest_dir(base_directory)
|
dest = site.in_dest_dir(base_directory)
|
||||||
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
||||||
path = File.join(path, "index.html") if url =~ /\/$/
|
path = File.join(path, "index.html") if url.end_with?("/")
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ module Jekyll
|
||||||
# Returns the destination file path String.
|
# Returns the destination file path String.
|
||||||
def destination(dest)
|
def destination(dest)
|
||||||
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
||||||
path = File.join(path, "index.html") if url =~ /\/$/
|
path = File.join(path, "index.html") if url.end_with?("/")
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ module Jekyll
|
||||||
def destination(dest)
|
def destination(dest)
|
||||||
# The url needs to be unescaped in order to preserve the correct filename
|
# The url needs to be unescaped in order to preserve the correct filename
|
||||||
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
||||||
path = File.join(path, "index.html") if self.url =~ /\/$/
|
path = File.join(path, "index.html") if self.url.end_with?("/")
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue