Skip to content

Commit

Permalink
[fix] Support proper local links
Browse files Browse the repository at this point in the history
Only borked ones were supported. The new behavior mimics Firefox.

The following incorrect varieties will be treated the same as the correct `file:///tmp/test.txt`.
* file:/tmp/test.txt
* file://tmp/test.txt

Fixes <koreader#5941>.

See <koreader#5941 (comment)> for discussion.
  • Loading branch information
Frenzie committed Mar 13, 2020
1 parent f9a57a3 commit 0e3a2f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/apps/reader/modules/readerlink.lua
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function ReaderLink:onGotoLink(link, neglect_current_location, allow_footnote_po
end

-- Check if it is a link to a local file
local linked_filename = link_url:gsub("^file:", "") -- remove local file protocol if any
local linked_filename = link_url:gsub("^file:/?/?", "") -- remove local file protocol if any
local anchor
if linked_filename:find("?") then -- remove any query string (including any following anchor)
linked_filename, anchor = linked_filename:match("^(.-)(%?.*)$")
Expand Down

0 comments on commit 0e3a2f3

Please sign in to comment.