Skip to content

Commit

Permalink
fix: only add file extension if its missing (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes authored Apr 1, 2024
1 parent 4767b23 commit ca9cc07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/img-clip/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ M.get_file_path = function(ext)
file_path = dir_path .. config_file_name
end

-- add file ext
file_path = M.add_file_ext(file_path, ext)
-- add file ext if missing
if vim.fn.fnamemodify(file_path, ":e") == "" then
file_path = M.add_file_ext(file_path, ext)
end
return file_path
end

Expand Down
2 changes: 2 additions & 0 deletions lua/img-clip/paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ end

---@param url string
M.paste_image_from_url = function(url)
-- if we are not downloading images, then just insert the url
if not config.get_opt("download_images") then
if not markup.insert_markup(url) then
util.error("Could not insert markup code.")
Expand Down Expand Up @@ -103,6 +104,7 @@ M.paste_image_from_path = function(src_path)
end
end

-- if we are not copying images, then just insert the original path
if not config.get_opt("copy_images") then
if not markup.insert_markup(src_path, true) then
util.error("Could not insert markup code.")
Expand Down

0 comments on commit ca9cc07

Please sign in to comment.