From ce5d421c982452739b0e94083d36c54daeb364ea Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Fri, 16 Aug 2024 01:54:44 -0400 Subject: [PATCH] fix: correct trim path (#22) --- lua/tiktoken_lib.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/tiktoken_lib.lua b/lua/tiktoken_lib.lua index f2811b666..c9dcc5d46 100644 --- a/lua/tiktoken_lib.lua +++ b/lua/tiktoken_lib.lua @@ -19,10 +19,15 @@ H.library_path = function() return dirname .. ("../build/?.%s"):format(ext) end +---@type fun(s: string): string +local trim_semicolon = function(s) + return s:sub(-1) == ";" and s:sub(1, -2) or s +end + M.load = function() local library_path = H.library_path() if not string.find(package.cpath, library_path, 1, true) then - package.cpath = package.cpath .. ";" .. library_path + package.cpath = trim_semicolon(package.cpath) .. ";" .. library_path end end