mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 14:32:44 +08:00
FIX: Update "Embed Motoko" Onebox URLs (#22198)
Embed Motoko service's primary URL is transiting from embed.smartcontracts.org to embed.motoko.org, this PR updates the Onebox logic to work for either domain.
This commit is contained in:
parent
6a4666456e
commit
44a104dff8
|
@ -6,8 +6,8 @@ module Onebox
|
|||
include Engine
|
||||
include StandardEmbed
|
||||
|
||||
matches_regexp(%r{^https?://embed\.smartcontracts\.org/?.*})
|
||||
requires_iframe_origins "https://embed.smartcontracts.org"
|
||||
matches_regexp(%r{^https?://embed\.(motoko|smartcontracts)\.org/?.*})
|
||||
requires_iframe_origins("https://embed.motoko.org", "https://embed.smartcontracts.org")
|
||||
always_https
|
||||
|
||||
def to_html
|
||||
|
@ -21,7 +21,7 @@ module Onebox
|
|||
protected
|
||||
|
||||
def get_oembed_url
|
||||
"https://embed.smartcontracts.org/api/onebox?url=#{url}"
|
||||
"https://embed.smartcontracts.org/services/onebox?url=#{url}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
RSpec.describe Onebox::Engine::MotokoOnebox do
|
||||
before do
|
||||
body =
|
||||
'{"version":"1.0","provider_name":"Embed Motoko","provider_url":"https://embed.smartcontracts.org","type":"rich","width":800,"height":500,"html":"<iframe src=\"https://embed.smartcontracts.org\" width=\"800\" height=\"500\" style=\"border:0\" />"}'
|
||||
'{"version":"1.0","provider_name":"Embed Motoko","provider_url":"https://embed.motoko.org","type":"rich","width":800,"height":500,"html":"<iframe src=\"https://embed.motoko.org\" width=\"800\" height=\"500\" style=\"border:0\" />"}'
|
||||
|
||||
stub_request(
|
||||
:get,
|
||||
"https://embed.smartcontracts.org/api/onebox?url=https://embed.smartcontracts.org",
|
||||
"https://embed.smartcontracts.org/services/onebox?url=https://embed.motoko.org",
|
||||
).to_return(status: 200, body: body, headers: {})
|
||||
end
|
||||
|
||||
it "returns the expected iframe markup" do
|
||||
expect(Onebox.preview("https://embed.smartcontracts.org").to_s.chomp).to include(
|
||||
'<iframe src="https://embed.smartcontracts.org" width="800" height="500" style="border:0"',
|
||||
expect(Onebox.preview("https://embed.motoko.org").to_s.chomp).to include(
|
||||
'<iframe src="https://embed.motoko.org" width="800" height="500" style="border:0"',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user