Skip to content

Commit eefe2a8

Browse files
committed
Add new figma embed script host embed.figma.com
1 parent 442ef3f commit eefe2a8

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

lib/qiita/markdown/embed/figma.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ module Qiita
44
module Markdown
55
module Embed
66
module Figma
7-
SCRIPT_HOST = "www.figma.com"
7+
SCRIPT_HOSTS = [
8+
"www.figma.com",
9+
"embed.figma.com",
10+
].freeze
811
end
912
end
1013
end

lib/qiita/markdown/transformers/filter_iframe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class FilterIframe
99
Embed::SlideShare::SCRIPT_HOST,
1010
Embed::GoogleSlide::SCRIPT_HOST,
1111
Embed::Docswell::SCRIPT_HOSTS,
12-
Embed::Figma::SCRIPT_HOST,
12+
Embed::Figma::SCRIPT_HOSTS,
1313
Embed::GoogleDrive::SCRIPT_HOST,
1414
Embed::StackBlitz::SCRIPT_HOST,
1515
Embed::BlueprintUe::SCRIPT_HOST,

spec/qiita/markdown/processor_spec.rb

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,25 +1632,33 @@
16321632

16331633
context "with HTML embed code for Figma" do
16341634
shared_examples "embed code figma example" do
1635-
let(:markdown) do
1636-
<<-MARKDOWN.strip_heredoc
1637-
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{url}"></iframe>
1638-
MARKDOWN
1639-
end
1640-
let(:url) { "#{scheme}//www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com" }
1641-
let(:encoded_url) { CGI.escapeHTML(url) }
1635+
[
1636+
"www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com",
1637+
"embed.figma.com/design/nrPSsILSYjesyc5UHjYYa4?embed_host=share",
1638+
].each do |script_url|
1639+
context "with HTML embed code for Figma using script url `#{script_url}`" do
1640+
let(:markdown) do
1641+
<<-MARKDOWN.strip_heredoc
1642+
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{url}"></iframe>
1643+
MARKDOWN
1644+
end
16421645

1643-
if allowed
1644-
it "does not sanitize embed code" do
1645-
should eq <<-HTML.strip_heredoc
1646-
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{encoded_url}"></iframe>
1647-
HTML
1648-
end
1649-
else
1650-
it "forces width attribute on iframe" do
1651-
should eq <<-HTML.strip_heredoc
1652-
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100%" height="100" src="#{encoded_url}"></iframe>
1653-
HTML
1646+
let(:url) { "#{scheme}//#{script_url}" }
1647+
let(:encoded_url) { CGI.escapeHTML(url) }
1648+
1649+
if allowed
1650+
it "does not sanitize embed code" do
1651+
should eq <<-HTML.strip_heredoc
1652+
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100" height="100" src="#{encoded_url}"></iframe>
1653+
HTML
1654+
end
1655+
else
1656+
it "forces width attribute on iframe" do
1657+
should eq <<-HTML.strip_heredoc
1658+
<iframe style="border: 1px solid rgba(0, 0, 0, 0.1);" width="100%" height="100" src="#{encoded_url}"></iframe>
1659+
HTML
1660+
end
1661+
end
16541662
end
16551663
end
16561664
end

0 commit comments

Comments
 (0)