Log a warning when the slug is empty (#7357)

Merge pull request 7357
This commit is contained in:
mo khan 2019-03-15 11:35:01 -06:00 committed by jekyllbot
parent 757f47b21c
commit 2bdf1a53c4
2 changed files with 6 additions and 0 deletions

View File

@ -222,6 +222,7 @@ module Jekyll
slug.gsub!(%r!^\-|\-$!i, "")
slug.downcase! unless cased
Jekyll.logger.warn("Warning:", "Empty `slug` generated for '#{string}'.") if slug.empty?
slug
end

View File

@ -282,6 +282,11 @@ class TestUtils < JekyllUnitTest
Utils.slugify("The _config.yml file?", :mode => "none", :cased => true)
)
end
should "records a warning in the log if the returned slug is empty" do
expect(Jekyll.logger).to receive(:warn)
assert_equal "", Utils.slugify("💎")
end
end
context "The \`Utils.titleize_slug\` method" do