A platform for community discussion. Free, open, simple.
FIX: pretty-text shims - getURL's baseUri (#20822)
Renato Atilio7afcb664fb21
diff --git a/lib/pretty_text/shims.js b/lib/pretty_text/shims.jsindex 1c54183c922..793a3992eb5 100644--- a/lib/pretty_text/shims.js+++ b/lib/pretty_text/shims.js@@ -78,7 +78,7 @@ function __getURLNoCDN(url) {return url;}- if (url.includes(__paths.baseUri)) {+ if (url.startsWith(`${__paths.baseUri}/`) || url === __paths.baseUri) {return url;}if (url[0] !== "/") {diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rbindex cf53fc17f72..30fb439ffa7 100644--- a/spec/lib/pretty_text_spec.rb+++ b/spec/lib/pretty_text_spec.rb@@ -1534,6 +1534,27 @@ RSpec.describe PrettyText doit "replaces Emoji from Unicode 14.0" doexpect(PrettyText.cook("🫣")).to match(/\:face_with_peeking_eye\:/)end++ context "with subfolder" do+ it "prepends the subfolder path to the emoji url" do+ set_subfolder "/forum"++ expected = "src=\"/forum/images/emoji/twitter/grinning.png?v=#{Emoji::EMOJI_VERSION}\""++ expect(PrettyText.cook("😀")).to include(expected)+ expect(PrettyText.cook(":grinning:")).to include(expected)+ end++ it "prepends the subfolder path even if it is part of the emoji url" do+ set_subfolder "/info"++ expected =+ "src=\"/info/images/emoji/twitter/information_source.png?v=#{Emoji::EMOJI_VERSION}\""++ expect(PrettyText.cook("ℹ️")).to include(expected)+ expect(PrettyText.cook(":information_source:")).to include(expected)+ end+ endenddescribe "custom emoji" do