FIX: pretty-text shims - getURL's baseUri (#20822)

This commit is contained in:
Renato Atilio 2023-03-30 09:35:06 -03:00 committed by GitHub
parent 74312a6c52
commit 7afcb664fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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] !== "/") {

View File

@ -1534,6 +1534,27 @@ RSpec.describe PrettyText do
it "replaces Emoji from Unicode 14.0" do
expect(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
end
end
describe "custom emoji" do