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:
Ryan Vandersmith 2023-07-25 19:41:01 -06:00 committed by GitHub
parent 6a4666456e
commit 44a104dff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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