mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Title prettify shoundn't downcase all non-ascii titles
This commit is contained in:
@@ -31,7 +31,7 @@ class TextCleaner
|
|||||||
# Replace ????? with a single ?
|
# Replace ????? with a single ?
|
||||||
text.gsub!(/\?+/, '?') if opts[:deduplicate_question_marks]
|
text.gsub!(/\?+/, '?') if opts[:deduplicate_question_marks]
|
||||||
# Replace all-caps text with regular case letters
|
# Replace all-caps text with regular case letters
|
||||||
text = text.mb_chars.downcase.to_s if opts[:replace_all_upper_case] && (text =~ /[A-Z]+/) && (text == text.upcase)
|
text = text.mb_chars.downcase.to_s if opts[:replace_all_upper_case] && (text == text.mb_chars.upcase)
|
||||||
# Capitalize first letter, but only when entire first word is lowercase
|
# Capitalize first letter, but only when entire first word is lowercase
|
||||||
first, rest = text.split(' ', 2)
|
first, rest = text.split(' ', 2)
|
||||||
if first && opts[:capitalize_first_letter] && first == first.mb_chars.downcase
|
if first && opts[:capitalize_first_letter] && first == first.mb_chars.downcase
|
||||||
|
|||||||
@@ -191,6 +191,10 @@ describe TextCleaner do
|
|||||||
expect(TextCleaner.clean_title("INVESTIGAÇÃO POLÍTICA NA CÂMARA")).to eq("Investigação política na câmara")
|
expect(TextCleaner.clean_title("INVESTIGAÇÃO POLÍTICA NA CÂMARA")).to eq("Investigação política na câmara")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't downcase text if only one word is upcase in a non-ascii alphabet" do
|
||||||
|
expect(TextCleaner.clean_title("«Эта неделя в EVE»")).to eq("«Эта неделя в EVE»")
|
||||||
|
end
|
||||||
|
|
||||||
it "capitalizes first unicode letter" do
|
it "capitalizes first unicode letter" do
|
||||||
expect(TextCleaner.clean_title("épico encontro")).to eq("Épico encontro")
|
expect(TextCleaner.clean_title("épico encontro")).to eq("Épico encontro")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user