A platform for community discussion. Free, open, simple.
FIX: chat message inline onebox url target (#33288)
David Battersbybb5c2e7a00eb
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-text.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-message-text.gjsindex d11621de771..cb6e2a1761a 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-text.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-text.gjs@@ -27,7 +27,7 @@ export default class ChatMessageText extends Component {<DecoratedHtml@html={{htmlSafe @cooked}}@decorate={{@decorate}}- @className=" chat-cooked"+ @className="chat-cooked"/>{{/if}}diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-decorators.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-decorators.jsindex 3c7b2c9b7e8..30b6be84453 100644--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-decorators.js+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-decorators.js@@ -114,7 +114,7 @@ export default {forceLinksToOpenNewTab(element) {const links = element.querySelectorAll(- ".chat-message-text a:not([target='_blank'])"+ "a:not([target]), a[target]:not([target='_blank'])");for (let linkIndex = 0; linkIndex < links.length; linkIndex++) {const link = links[linkIndex];diff --git a/plugins/chat/spec/system/chat_message_onebox_spec.rb b/plugins/chat/spec/system/chat_message_onebox_spec.rbindex cdb5bc15b7b..23462296469 100644--- a/plugins/chat/spec/system/chat_message_onebox_spec.rb+++ b/plugins/chat/spec/system/chat_message_onebox_spec.rb@@ -24,15 +24,27 @@ RSpec.describe "Chat message onebox", type: :system do</article></aside>HTML++ inline_onebox_html = <<~HTML.chomp+ <a class="inline-onebox" href="https://example.com">example.com</a>+ HTML+Oneboxer.stubs(:cached_onebox).with("https://en.wikipedia.org/wiki/Hyperlink").returns(full_onebox_html)+ Oneboxer.stubs(:cached_onebox).with("https://example.com").returns(inline_onebox_html)+stub_request(:get, "https://en.wikipedia.org/wiki/Hyperlink").to_return(status: 200,body: "<html><head><title>a</title></head></html>",)++ stub_request(:get, "https://example.com").to_return(+ status: 200,+ body: "<html><head><title>b</title></head></html>",+ )endit "is oneboxed" do@@ -41,5 +53,12 @@ RSpec.describe "Chat message onebox", type: :system doexpect(page).to have_content("This is a test", wait: 20)end++ it "is inline oneboxed with _blank target attribute" do+ chat_page.visit_channel(channel_1)+ channel_page.send_message("test message - https://example.com")++ expect(page).to have_selector(".chat-cooked a[target='_blank']", text: "example.com")+ endendend