Skip to content

Commit

Permalink
fix: correct trim path (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnphm authored Aug 16, 2024
1 parent de22014 commit ce5d421
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/tiktoken_lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ce5d421

Please sign in to comment.