Added unit test for special character, fixed error that it exposed.

This commit is contained in:
Eldritch Cheese 2016-11-26 22:31:03 -05:00
parent bbdeb32f38
commit a55760d4ad
3 changed files with 35 additions and 1 deletions

View File

@ -16,7 +16,7 @@ module Jekyll
escaped_slug = Regexp.escape(slug)
@name_regex = %r!^_posts/#{path}#{date}-#{escaped_slug}\.[^.]+|
^#{path}_posts/?#{date}-#{slug}\.[^.]+!x
^#{path}_posts/?#{date}-#{escaped_slug}\.[^.]+!x
end
def post_date

View File

@ -0,0 +1,8 @@
---
layout: default
title: Special Characters
---
url: {{ page.url }}
date: {{ page.date }}
id: {{ page.id }}

View File

@ -554,6 +554,32 @@ CONTENT
end
end
context "simple page with post linking containing special characters" do
setup do
content = <<CONTENT
---
title: Post linking
---
{% post_url 2016-11-26-special-chars-(+) %}
CONTENT
create_post(content, {
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true
})
end
should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result)
end
should "have the URL to the \"complex\" post from 2008-11-21" do
assert_match %r!/2016/11/26/special-chars-\(\+\)/!, @result
end
end
context "simple page with nested post linking" do
setup do
content = <<CONTENT