We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a92e764 commit bf38b05Copy full SHA for bf38b05
lua/leetcode/cache/cookie.lua
@@ -41,6 +41,17 @@ function Cookie.delete()
41
return pcall(path.rm, file)
42
end
43
44
+---@return string|nil
45
+function Cookie.read()
46
+ local contents = file:read()
47
+
48
+ if not contents or type(contents) ~= "string" then
49
+ return
50
+ end
51
52
+ return select(1, contents:gsub("^%s*(.-)%s*$", "%1"))
53
+end
54
55
---@return lc.cache.Cookie | nil
56
function Cookie.get()
57
if not file:exists() then
@@ -55,8 +66,8 @@ function Cookie.get()
66
return hcookie
67
68
58
- local contents = file:read()
59
- if not contents or type(contents) ~= "string" then
69
+ local contents = Cookie.read()
70
+ if not contents then
60
71
require("leetcode.command").delete_cookie()
61
72
return
62
73
0 commit comments