[deploy] Fix case sensitive published bug (#10352)
This commit is contained in:
parent
cc694146e6
commit
b65ebdf99c
2 changed files with 18 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ class MarkdownFixer
|
|||
class << self
|
||||
def fix_all(markdown)
|
||||
methods = %i[
|
||||
add_quotes_to_title add_quotes_to_description
|
||||
add_quotes_to_title add_quotes_to_description lowercase_published
|
||||
modify_hr_tags convert_new_lines split_tags underscores_in_usernames
|
||||
]
|
||||
methods.reduce(markdown) { |acc, elem| public_send(elem, acc) }
|
||||
|
|
@ -36,6 +36,12 @@ class MarkdownFixer
|
|||
end
|
||||
end
|
||||
|
||||
def lowercase_published(markdown)
|
||||
markdown.gsub(/-{3}.*?-{3}/m) do |front_matter|
|
||||
front_matter.gsub(/^published: /i, "published: ")
|
||||
end
|
||||
end
|
||||
|
||||
def convert_new_lines(markdown)
|
||||
markdown.gsub("\r\n", "\n")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ RSpec.describe MarkdownFixer, type: :labor do
|
|||
<<~HEREDOC
|
||||
---
|
||||
title: #{title}
|
||||
published: false
|
||||
description: #{description}
|
||||
---
|
||||
HEREDOC
|
||||
|
|
@ -98,6 +99,16 @@ RSpec.describe MarkdownFixer, type: :labor do
|
|||
end
|
||||
end
|
||||
|
||||
describe "::lowercase_published" do
|
||||
it "lowercases the published frontmatter attribute" do
|
||||
cases = %w[Published pubLished PUBLISHED]
|
||||
cases.each do |_word|
|
||||
result = described_class.lowercase_published(front_matter)
|
||||
expect(result.match(/^published: false/).size).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "::fix_all" do
|
||||
it "escapes title and description" do
|
||||
result = described_class
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue