fix date parsing in file names

This commit is contained in:
jona 2016-11-29 09:14:03 +01:00
parent 4bd6240a1d
commit fac041933c
3 changed files with 35 additions and 1 deletions

View File

@ -9,7 +9,7 @@ module Jekyll
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
DATELESS_FILENAME_MATCHER = %r!^(?:.+/)*(.*)(\.[^.]+)$!
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$!
DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{4}-\d{2}-\d{2})-(.*)(\.[^.]+)$!
# Create a new Document.
#

View File

@ -0,0 +1,5 @@
---
title: "this is a test!"
---
wheee

View File

@ -492,4 +492,33 @@ class TestDocument < JekyllUnitTest
assert_equal true, File.file?(@dest_file)
end
end
context "a document in a collection with dash-separated numeric file name" do
setup do
@site = fixture_site({
"collections" => {
"methods" => {
"output" => true
}
}
})
@site.process
@document = @site.collections["methods"].docs.find do |doc|
doc.relative_path == "_methods/3940394-21-9393050-fifif1323-test.md"
end
@dest_file = dest_dir("methods/3940394-21-9393050-fifif1323-test.html")
end
should "produce the right URL" do
assert_equal "/methods/3940394-21-9393050-fifif1323-test.html", @document.url
end
should "produce the right destination" do
assert_equal @dest_file, @document.destination(dest_dir)
end
should "be output in the correct place" do
assert_equal true, File.file?(@dest_file)
end
end
end