commit f5656546565399a0bab7caa76edc1b94e63d8eb1
parent 0236724c83b0405c951737a396ba65b4738c2d62
Author: Hugo Soucy <hugo@soucy.cc>
Date: Wed, 29 Aug 2018 06:09:16 -0400
Use `path.basename` instead of a regular expression
Diffstat:
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/ferron/static.lua b/ferron/static.lua
@@ -19,9 +19,8 @@ function static.dispatch(file)
function(f)
if fileutils.isNonTextual(f) then
local listindex_dirname = path.dirname(file)
- local img = f
- local img_name = img:match("^.+/(.+)$")
- local htmlfolder = Ferron.site.path .. Ferron.site.siteconfig.paths.html
+ local img = f
+ local htmlfolder = Ferron.site.path .. Ferron.site.siteconfig.paths.html
if not posix.readlink(img) then
-- Copy content's images in the `public_html/` directory
@@ -31,7 +30,7 @@ function static.dispatch(file)
-- non-textuals for list index pages
if path.isfile(htmlfolder .. fileutils.getrelpath(img)) then
lfs.link("." .. img:sub((listindex_dirname):len() + 1),
- htmlfolder .. fileutils.getrelpath(path.dirname(file)) .. "/" .. img_name, true)
+ htmlfolder .. fileutils.getrelpath(path.dirname(file)) .. "/" .. path.basename(img), true)
end
end
end