Merge pull request #4401 from jekyll/fix-documents-with-permalink-with-slash
Merge pull request 4401
This commit is contained in:
		
						commit
						a4ba8246d7
					
				| 
						 | 
				
			
			@ -168,7 +168,7 @@ module Jekyll
 | 
			
		|||
    private
 | 
			
		||||
 | 
			
		||||
    def permalink_ext
 | 
			
		||||
      if document.permalink
 | 
			
		||||
      if document.permalink && !document.permalink.end_with?("/")
 | 
			
		||||
        permalink_ext = File.extname(document.permalink)
 | 
			
		||||
        permalink_ext unless permalink_ext.empty?
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
---
 | 
			
		||||
permalink: /with.dots/permalink.with.slash.tho/
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
I'm a file with dots BUT I have a permalink which ends with a slash.
 | 
			
		||||
| 
						 | 
				
			
			@ -203,7 +203,7 @@ class TestCollections < JekyllUnitTest
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    should "contain one document" do
 | 
			
		||||
      assert_equal 2, @collection.docs.size
 | 
			
		||||
      assert_equal 3, @collection.docs.size
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "allow dots in the filename" do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -207,6 +207,10 @@ class TestDocument < JekyllUnitTest
 | 
			
		|||
    should "produce the right destination file" do
 | 
			
		||||
      assert_equal @dest_file, @document.destination(dest_dir)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "honor the output extension of its permalink" do
 | 
			
		||||
      assert_equal ".html", @document.output_ext
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context "a document in a collection with pretty permalink style" do
 | 
			
		||||
| 
						 | 
				
			
			@ -267,6 +271,10 @@ class TestDocument < JekyllUnitTest
 | 
			
		|||
      @dest_file = dest_dir("slides/example-slide-7.php")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "be written out properly" do
 | 
			
		||||
      assert_exist @dest_file
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "produce the permalink as the url" do
 | 
			
		||||
      assert_equal "/slides/example-slide-7.php", @document.url
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -274,6 +282,10 @@ class TestDocument < JekyllUnitTest
 | 
			
		|||
    should "be written to the proper directory" do
 | 
			
		||||
      assert_equal @dest_file, @document.destination(dest_dir)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "honor the output extension of its permalink" do
 | 
			
		||||
      assert_equal ".php", @document.output_ext
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context "documents in a collection with custom title permalinks" do
 | 
			
		||||
| 
						 | 
				
			
			@ -318,6 +330,29 @@ class TestDocument < JekyllUnitTest
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context "document with a permalink with dots & a trailing slash" do
 | 
			
		||||
    setup do
 | 
			
		||||
      @site = fixture_site({"collections" => {
 | 
			
		||||
        "with.dots" => { "output" => true }
 | 
			
		||||
      }})
 | 
			
		||||
      @site.process
 | 
			
		||||
      @document = @site.collections["with.dots"].docs.last
 | 
			
		||||
      @dest_file = dest_dir("with.dots", "permalink.with.slash.tho", "index.html")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "yield an HTML document" do
 | 
			
		||||
      assert_equal @dest_file, @document.destination(dest_dir)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "be written properly" do
 | 
			
		||||
      assert_exist @dest_file
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    should "get the right output_ext" do
 | 
			
		||||
      assert_equal ".html", @document.output_ext
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context "documents in a collection" do
 | 
			
		||||
    setup do
 | 
			
		||||
      @site = fixture_site({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue