diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 2f7803d5..730af13f 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -78,6 +78,7 @@ module Jekyll # sanitize url @url = url.split('/').reject{ |part| part =~ /^\.+$/ }.join('/') @url += "/" if url =~ /\/$/ + @url.gsub!(/\A([^\/])/, '/\1') @url end diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 9824ef02..388c86c3 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -228,6 +228,7 @@ module Jekyll # sanitize url @url = url.split('/').reject{ |part| part =~ /^\.+$/ }.join('/') @url += "/" if url =~ /\/$/ + @url.gsub!(/\A([^\/])/, '/\1') @url end diff --git a/site/_posts/2012-07-01-variables.md b/site/_posts/2012-07-01-variables.md index 7f577ecb..9b969e83 100644 --- a/site/_posts/2012-07-01-variables.md +++ b/site/_posts/2012-07-01-variables.md @@ -176,7 +176,8 @@ following is a reference of the available data.

page.url

- The URL of the Post without the domain. e.g. + The URL of the Post without the domain, but + with a leading slash, e.g. /2008/12/14/my-post.html

diff --git a/test/test_post.rb b/test/test_post.rb index 9fe29100..1d7b8539 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -71,8 +71,8 @@ class TestPost < Test::Unit::TestCase @post.read_yaml(@source, file) assert_equal "my_category/permalinked-post", @post.permalink - assert_equal "my_category", @post.dir - assert_equal "my_category/permalinked-post", @post.url + assert_equal "/my_category", @post.dir + assert_equal "/my_category/permalinked-post", @post.url end context "with CRLF linebreaks" do