From 4fbbeddae20fa52732f30ef001bb1f80258bc5d7 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 25 May 2016 17:57:09 -0700 Subject: [PATCH] Fix Page#relative_path so that it consistently does NOT have the prepending slash (previously inconsistent) Fixes for #4946 --- lib/jekyll/page.rb | 4 ++-- test/test_front_matter_defaults.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 3f984709..1542e986 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -135,12 +135,12 @@ module Jekyll # # Returns the path to the source file def path - data.fetch("path") { relative_path.sub(%r{!\A\/!}, "") } + data.fetch("path") { relative_path } end # The path to the page source file, relative to the site source def relative_path - File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)) + File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r{\A\/}, "") end # Obtain destination path. diff --git a/test/test_front_matter_defaults.rb b/test/test_front_matter_defaults.rb index f1b55ac1..51308016 100644 --- a/test/test_front_matter_defaults.rb +++ b/test/test_front_matter_defaults.rb @@ -17,7 +17,7 @@ class TestFrontMatterDefaults < JekyllUnitTest }] })) @site.process - @affected = @site.pages.find { |page| page.relative_path == "/contacts/bar.html" } + @affected = @site.pages.find { |page| page.relative_path == "contacts/bar.html" } @not_affected = @site.pages.find { |page| page.relative_path == "about.html" } end