mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Allow svg in oneboxer in certain cases (#19253)
When doing local oneboxes we sometimes want to allow SVGs in the final preview HTML. The main case currently is for the new cooked hashtags, which include an SVG icon. SVGs will be included in local oneboxes via `ExcerptParser` _only_ if they have the d-icon class, and if the caller for `post.excerpt` specifies the `keep_svg: true` option.
This commit is contained in:
@ -146,6 +146,16 @@ RSpec.describe Oneboxer do
|
||||
|
||||
expect(preview("/u/#{user.username}")).to include("Thunderland")
|
||||
end
|
||||
|
||||
it "includes hashtag HTML and icons" do
|
||||
SiteSetting.enable_experimental_hashtag_autocomplete = true
|
||||
category = Fabricate(:category, slug: "random")
|
||||
Fabricate(:tag, name: "bug")
|
||||
public_post = Fabricate(:post, raw: "This post has some hashtags, #random and #bug")
|
||||
expect(preview(public_post.url).chomp).to include(<<~HTML.chomp)
|
||||
<a class="hashtag-cooked" href="#{category.url}" data-type="category" data-slug="random"><svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg>#{category.name}</a> and <a class="hashtag-cooked" href="/tag/bug" data-type="tag" data-slug="bug"><svg class="fa d-icon d-icon-tag svg-icon svg-node"><use href="#tag"></use></svg>bug</a>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
|
||||
describe ".onebox_raw" do
|
||||
|
Reference in New Issue
Block a user