Skip to content

Commit

Permalink
Fixes entry parse if there is no URL
Browse files Browse the repository at this point in the history
  • Loading branch information
naps62 committed Mar 30, 2018
1 parent 2ac95a2 commit 727eaf7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/repositories/story_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ def self.extract_content(entry)
sanitized_content = sanitize(entry.summary)
end

expand_absolute_urls(sanitized_content, entry.url)
if entry.url.present?
expand_absolute_urls(sanitized_content, entry.url)
else
sanitized_content
end
end

def self.extract_title(entry)
Expand Down
16 changes: 16 additions & 0 deletions spec/repositories/story_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@
it "falls back to summary if there is no content" do
expect(StoryRepository.extract_content(summary_only)).to eq "Dumb publisher"
end

it "expands urls" do
entry = double(url: "http://mdswanson.com",
content: nil,
summary: "<a href=\"page\">Page</a>")

expect(StoryRepository.extract_content(entry)).to eq "<a href=\"http://mdswanson.com/page\">Page</a>"
end

it "ignores URL expansion if entry url is nil" do
entry = double(url: nil,
content: nil,
summary: "<a href=\"page\">Page</a>")

expect(StoryRepository.extract_content(entry)).to eq "<a href=\"page\">Page</a>"
end
end

describe ".sanitize" do
Expand Down

0 comments on commit 727eaf7

Please sign in to comment.