mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
fix: sanitize title input (prevent double extension)
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user