diff --git a/spec/components/page_content_spec.cr b/spec/components/page_content_spec.cr index 983b263..f9c537f 100644 --- a/spec/components/page_content_spec.cr +++ b/spec/components/page_content_spec.cr @@ -156,7 +156,13 @@ describe PageContent do html = PageContent.new(page: page).render_to_string - html.should eq %(

Click to visit embedded content

) + html.should eq stripped_html <<-HTML +

+

+ Embedded content at example.com +
+

+ HTML end it "renders an ordered list" do diff --git a/spec/models/nodes_spec.cr b/spec/models/nodes_spec.cr index dc46144..f9a43ac 100644 --- a/spec/models/nodes_spec.cr +++ b/spec/models/nodes_spec.cr @@ -1,6 +1,14 @@ require "../spec_helper" module Nodes + describe IFrame do + it "returns embedded url with subdomains" do + iframe = IFrame.new(href: "https://dev.example.com/page") + + iframe.domain.should eq("dev.example.com") + end + end + describe Image do it "adjusts the width and height proportionally" do image = Image.new(src: "image.png", originalWidth: 1000, originalHeight: 603) diff --git a/src/components/page_content.cr b/src/components/page_content.cr index a4213a1..3019b6e 100644 --- a/src/components/page_content.cr +++ b/src/components/page_content.cr @@ -57,7 +57,7 @@ class PageContent < BaseComponent def render_child(child : IFrame) div class: "embedded" do a href: child.href do - text "Click to visit embedded content" + text "Embedded content at #{child.domain}" end end end diff --git a/src/models/nodes.cr b/src/models/nodes.cr index da55d66..9241e00 100644 --- a/src/models/nodes.cr +++ b/src/models/nodes.cr @@ -123,6 +123,10 @@ module Nodes def initialize(@href : String) end + def domain + URI.parse(href).host + end + def ==(other : IFrame) other.href == href end