From b1049c84cd369ce565ad9925ed6d53546eeca8de Mon Sep 17 00:00:00 2001 From: Leandro Lisboa Penz Date: Sun, 5 Sep 2010 18:11:09 -0300 Subject: [PATCH] Correctly generates file basename. Fixes #208. The previous procedure generated invalid basenames when the filename had more than one dot. --- History.txt | 4 ++++ lib/jekyll/page.rb | 2 +- test/source/deal.with.dots.html | 7 +++++++ test/test_page.rb | 10 ++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/source/deal.with.dots.html diff --git a/History.txt b/History.txt index 20ce3958..ba13f283 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,7 @@ +== HEAD + * Bug Fixes + * Fixed filename basename generation (#208) + == 0.7.0 / 2010-08-24 * Minor Enhancements * Add support for rdiscount extensions (#173) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 3cdce5df..c4143424 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -71,7 +71,7 @@ module Jekyll # Returns nothing def process(name) self.ext = File.extname(name) - self.basename = name.split('.')[0..-2].first + self.basename = name[0 .. -self.ext.length-1] end # Add any necessary layouts to this post diff --git a/test/source/deal.with.dots.html b/test/source/deal.with.dots.html new file mode 100644 index 00000000..a69dac8c --- /dev/null +++ b/test/source/deal.with.dots.html @@ -0,0 +1,7 @@ +--- +title: Deal with dots +permalink: /deal.with.dots/ +--- + +Let's test if jekyll deals properly with dots. + diff --git a/test/test_page.rb b/test/test_page.rb index 6fbb003d..6c82fcac 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -23,6 +23,16 @@ class TestPage < Test::Unit::TestCase assert_equal "/contacts.html", @page.url end + should "deal properly with extensions" do + @page = setup_page('deal.with.dots.html') + assert_equal ".html", @page.ext + end + + should "deal properly with dots" do + @page = setup_page('deal.with.dots.html') + assert_equal "deal.with.dots", @page.basename + end + context "with pretty url style" do setup do @site.permalink_style = :pretty