Merge pull request #17 from lambtho12/main

fix: sanitize title input (prevent double extension)
This commit is contained in:
Rene Schallner
2021-12-01 15:14:19 +01:00
committed by GitHub

View File

@@ -473,7 +473,7 @@ local function FollowLink(opts)
local search_mode = "files" local search_mode = "files"
local parts = vim.split(title, "#") local parts = vim.split(title, "#")
local filename = '' local filename = ""
-- if there is a # -- if there is a #
if #parts ~= 1 then if #parts ~= 1 then
@@ -781,6 +781,7 @@ local function CreateNote(_)
-- vim.ui.input causes ppl problems - see issue #4 -- vim.ui.input causes ppl problems - see issue #4
-- vim.ui.input({ prompt = "Title: " }, on_create) -- vim.ui.input({ prompt = "Title: " }, on_create)
local title = vim.fn.input("Title: ") local title = vim.fn.input("Title: ")
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
if #title > 0 then if #title > 0 then
on_create(title) on_create(title)
end end
@@ -828,6 +829,7 @@ local function CreateNoteSelectTemplate(_)
-- vim.ui.input causes ppl problems - see issue #4 -- vim.ui.input causes ppl problems - see issue #4
-- vim.ui.input({ prompt = "Title: " }, on_create_with_template) -- vim.ui.input({ prompt = "Title: " }, on_create_with_template)
local title = vim.fn.input("Title: ") local title = vim.fn.input("Title: ")
title = title:gsub("[" .. M.Cfg.extension .. "]+$", "")
if #title > 0 then if #title > 0 then
on_create_with_template(title) on_create_with_template(title)
end end