refact: file_extension

This commit is contained in:
Thomas Lambert
2023-04-29 00:24:24 +02:00
parent 4e2a433178
commit 0367fa6a66
2 changed files with 6 additions and 9 deletions

View File

@@ -15,6 +15,11 @@ function M.file_exists(fname)
end
end
-- Returns the file extension
function M.get_extension(fname)
return fname:match("^.+(%..+)$")
end
-- Strips an extension from a file name, escaping "." properly, eg:
-- strip_extension("path/Filename.md", ".md") -> "path/Filename"
local function strip_extension(str, ext)