From 2bdf1a53c40dc2eea8a939a61a411b723f909ed4 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 15 Mar 2019 11:35:01 -0600 Subject: [PATCH] Log a warning when the slug is empty (#7357) Merge pull request 7357 --- lib/jekyll/utils.rb | 1 + test/test_utils.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index 1444058b..dc5eea2f 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -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 diff --git a/test/test_utils.rb b/test/test_utils.rb index 509f92e8..8089f006 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -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