Skip to content

Commit

Permalink
Merge pull request #38 from prismicio/sre/oembed-html
Browse files Browse the repository at this point in the history
Fix oembed serialisation
  • Loading branch information
srenault authored Aug 29, 2019
2 parents b377596 + 6fe1e31 commit 90a8656
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/prismic.tests/FragmentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ public void ShouldParseOEmbed()
var structuredText = prismic.fragments.StructuredText.Parse(json);
prismic.fragments.StructuredText.Embed soundcloud = (prismic.fragments.StructuredText.Embed)structuredText.Blocks [0];
prismic.fragments.StructuredText.Embed youtube = (prismic.fragments.StructuredText.Embed)structuredText.Blocks [1];

Assert.IsNull (soundcloud.Obj.Width);
Assert.AreEqual (youtube.Obj.Width, 480);
}
Assert.AreEqual(youtube.Obj.AsHtml(), "<div data-oembed=\"https://www.youtube.com/watch?v=XMXgHfHxKVM\" data-oembed-type=\"video\" data-oembed-provider=\"youtube\"><iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/XMXgHfHxKVM?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe></div>");

}

[Test()]
public void ShouldAccessRaw()
Expand Down
2 changes: 1 addition & 1 deletion src/prismic/Fragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public Embed(String type, String provider, String url, int? width, int? height,
}

public String AsHtml() {
var providerAttr = provider != null ? ("\" data-oembed-provider=\"" + provider.ToLower () + "\"") : "";
var providerAttr = provider != null ? (" data-oembed-provider=\"" + provider.ToLower () + "\"") : "";
return ("<div data-oembed=\"" + url + "\" data-oembed-type=\"" + type.ToLower() + "\"" + providerAttr + ">" + html + "</div>");
}

Expand Down

0 comments on commit 90a8656

Please sign in to comment.