Skip to content

Commit c9e5e3a

Browse files
authored
add DevTool.normalizeSecretValue helper
1 parent 4e0e715 commit c9e5e3a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Utilities/Utils.lua

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ local DevTool = addonTable.DevTool
1010
--- UTILS
1111
-----------------------------------------------------------------------------------------------
1212

13+
function DevTool.normalizeSecretValue(value)
14+
if issecrettable(value) then
15+
return "<SECRET TABLE>"
16+
end
17+
if issecretvalue(value) then
18+
return "<SECRET VALUE>"
19+
end
20+
return value
21+
end
22+
1323
--- Math
1424

1525
function DevTool.round(num, idp)
@@ -174,6 +184,8 @@ function DevTool.ToUIString(value, name, withoutLineBrakes)
174184
result = tostring(value)
175185
end
176186

187+
result = DevTool.normalizeSecretValue(result)
188+
177189
if withoutLineBrakes then
178190
result = string.gsub(string.gsub(tostring(result), "|n", ""), "\n", "")
179191
end
@@ -188,8 +200,9 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
188200
-- try to get frame name
189201
if ok then
190202
local concat = function(str, before, after)
191-
before = before or ""
192-
after = after or ""
203+
before = DevTool.normalizeSecretValue(before) or ""
204+
after = DevTool.normalizeSecretValue(after) or ""
205+
str = DevTool.normalizeSecretValue(str)
193206
if str then
194207
return resultStr .. " " .. before .. str .. after
195208
end
@@ -211,6 +224,8 @@ function DevTool.GetObjectInfoFromWoWAPI(helperText, value)
211224
tostring(DevTool.round(height)) .. "]")
212225
end
213226

227+
name = DevTool.normalizeSecretValue(name)
228+
214229
if helperText ~= name then
215230
resultStr = concat(name, DevTool.colors.gray:WrapTextInColorCode("<"), DevTool.colors.gray:WrapTextInColorCode(">"))
216231
end
@@ -284,4 +299,4 @@ function DevTool.GetParentTable(info)
284299
end
285300

286301
return parent
287-
end
302+
end

0 commit comments

Comments
 (0)