mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[plugin] NewsDownloader: add primitive support for relative URLs (#12980)
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
Some checks are pending
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (10.15, 13, x86-64, 15.2) (push) Waiting to run
macos / macOS ${{ matrix.image }} ${{ matrix.platform }} 🔨${{ matrix.xcode_version }} 🎯${{ matrix.deployment_target }} (11.0, 14, ARM64, 15.4) (push) Waiting to run
Fixes #8611.
This commit is contained in:
@@ -614,6 +614,24 @@ function NewsDownloader:createFromDescription(feed, title, content, feed_output_
|
||||
logger.dbg("NewsDownloader: News file will be stored to :", news_file_path)
|
||||
local article_message = T(_("%1\n%2"), message, title_with_date)
|
||||
local footer = _("If this is only a summary, the full article can be downloaded by going to the News Downloader settings and changing 'Download full article' to 'true'.")
|
||||
|
||||
local base_url = getFeedLink(feed.link)
|
||||
if base_url then
|
||||
if not base_url:match("/$") then
|
||||
base_url = base_url .. "/"
|
||||
end
|
||||
content = content:gsub('href="(.-)"', function(link)
|
||||
if link:match("^/") then
|
||||
local base_url_domain_only = base_url:match("^(.-://[^/]+)/")
|
||||
return 'href="' .. base_url_domain_only .. link .. '"'
|
||||
end
|
||||
if not link:match("^[a-zA-Z][a-zA-Z0-9+.-]*://") then
|
||||
link = base_url .. link
|
||||
end
|
||||
return 'href="' .. link .. '"'
|
||||
end)
|
||||
end
|
||||
|
||||
local html = string.format([[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
Reference in New Issue
Block a user