Use the rss item's url when handling relative image links (#15497)
* Use the feed source url when the feed url (from links) is empty This probably should just be using @feed_source_url always to make a base path for absolute paths without a hostname, rather than expecting this from the feed. An example why we should not be using @feed.url would be individual posts at domain/slug but the "index" page at domain/blog (with a generic screen on /), and images hosted from /assets/ without /blog/ anywhere in the asset path. Partial fix for #15488 * Use item.url as base_url for relative links It's possible the rss feed and the contained articles are served from separate hosts/subdomains/paths. Don't assume the entries are related to the feed or the feed_source_url, use the item's url for relative links in that item. * Update failing spec to add url to item double
This commit is contained in:
parent
11cabac518
commit
64568d3a3d
2 changed files with 9 additions and 1 deletions
|
|
@ -31,6 +31,13 @@ module Feeds
|
|||
|
||||
private
|
||||
|
||||
def base_url
|
||||
@base_url ||=
|
||||
URI.parse(@item.url).then do |uri|
|
||||
"#{uri.scheme}://#{uri.host}"
|
||||
end
|
||||
end
|
||||
|
||||
def processed_title
|
||||
@title.truncate(128, omission: "...", separator: " ")
|
||||
end
|
||||
|
|
@ -43,7 +50,7 @@ module Feeds
|
|||
|
||||
def assemble_body_markdown
|
||||
cleaned_content = Feeds::CleanHtml.call(get_content)
|
||||
cleaned_content = thorough_parsing(cleaned_content, @feed.url)
|
||||
cleaned_content = thorough_parsing(cleaned_content, base_url)
|
||||
|
||||
content = ReverseMarkdown
|
||||
.convert(cleaned_content, github_flavored: true)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ RSpec.describe Feeds::AssembleArticleMarkdown, type: :service do
|
|||
categories: %w[tag1 tag2 tag3 tag4 tag5],
|
||||
published: "2020-12-20",
|
||||
content: content,
|
||||
url: "https://feed.source",
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue