fix(link): split links with string.split captured at load

LinkUtil.SplitLinkData and SplitLinkOptions looked up string.split on
every call. BigWigs (pepopo978 fork) defines a table-returning
string:split in Plugins/SpellRequests.lua, which replaces the global, so
with it loaded every custom link type resolved to a table, no handler
matched, and SetItemRef rejected the link as unknown.

string.split is registered in C by the DLL before any addon loads, so a
file-local captured when LinkUtil.lua loads always holds the real one.

Fixes brues-code/pfUI#73
This commit is contained in:
Brues
2026-11-02 16:23:36 -06:00
parent 1cdd46958f
commit 3a4d291748
@@ -1,3 +1,5 @@
local strsplit = string.split;
LinkTypes = {
AADCOpenConfig = "aadcopenconfig",
Action = "action",
@@ -75,7 +77,7 @@ function LinkUtil.FormatLink(linkType, linkDisplayText, ...)
end
function LinkUtil.SplitLinkData(linkData)
local linkType, linkOptions = string.split(":", linkData, 2);
local linkType, linkOptions = strsplit(":", linkData, 2);
linkOptions = linkOptions or ""; -- Could be nil if there's no ":" in linkData.
return linkType, linkOptions;
end
@@ -85,7 +87,7 @@ function LinkUtil.SplitLink(link) -- returns linkText and displayText
end
function LinkUtil.SplitLinkOptions(linkOptions)
return string.split(":", linkOptions);
return strsplit(":", linkOptions);
end
-- Extract the first link from the text given, ignoring leading and trailing characters.