Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,20 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
end

for j=1,#buildSites.websiteList do
if urlText:match(buildSites.websiteList[j].matchURL) then
self.controls.importCodeIn.text = urlText
self.importCodeValid = true
self.importCodeDetail = colorCodes.POSITIVE.."URL is valid ("..buildSites.websiteList[j].label..")"
self.importCodeSite = j
if buf ~= urlText then
self.controls.importCodeIn:SetText(urlText, false)
local matchURL = buildSites.websiteList[j].matchURL
local matchURLs = type() == "table" and matchURL or { matchURL }
for _, v in ipairs(matchURLs) do
if urlText:match(v) then
self.controls.importCodeIn.text = urlText
self.importCodeValid = true
self.importCodeDetail = colorCodes.POSITIVE ..
"URL is valid (" .. buildSites.websiteList[j].label .. ")"
self.importCodeSite = j
if buf ~= urlText then
self.controls.importCodeIn:SetText(urlText, false)
end
return
end
return
end
end

Expand Down
19 changes: 17 additions & 2 deletions src/Modules/BuildSiteTools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ buildSites.websiteList = {
codeOut = "https://pobb.in/", postUrl = "https://pobb.in/pob/", postFields = "", linkURL = "pobb.in/%1"
},
{
label = "poe.ninja", id = "PoeNinja", matchURL = "^https://poe2?%.ninja/?p?o?e?2?/pob/.+", regexURL = "poe2?%.ninja/?p?o?e?2?/pob/(.+)%s*$", downloadURL = "poe.ninja/poe2/pob/raw/%1",
label = "poe.ninja",
id = "PoeNinja",
matchURL = { "^https://poe2?%.ninja/?p?o?e?2?/pob/.+", "^https://poe2?%.ninja/?p?o?e?2?/profile/.+/.+/character/.+" },
regexURL = { "poe2?%.ninja/?p?o?e?2?/pob/(.+)%s*$", "poe2?%.ninja/?p?o?e?2?/profile/(.+)/(.+)/character/(.+)%s*$" },
downloadURL = { "poe.ninja/poe2/pob/raw/%1", "poe.ninja/poe2/pob/raw/profile/code/%1/%2/%3" },
codeOut = "", postUrl = "https://poe.ninja/poe2/pob/api/upload", postFields = "code=", linkURL="poe.ninja/poe2/pob/%1"
},
{
Expand Down Expand Up @@ -96,7 +100,18 @@ function buildSites.DownloadBuild(link, websiteInfo, callback)
end
end
else -- called via the ImportTab
siteCodeURL = link:gsub(websiteInfo.regexURL, websiteInfo.downloadURL)
-- if the site supports multiple endpoints, use the first one that matches
if type(websiteInfo.regexURL) == "table" then
for i = 1, #websiteInfo.regexURL do
if link:match(websiteInfo.matchURL[i]) then
siteCodeURL = link:gsub(websiteInfo.regexURL[i], websiteInfo.downloadURL[i])
break
end
end
else
siteCodeURL = link:gsub(websiteInfo.regexURL, websiteInfo.downloadURL)
end
ConPrintf("%s", siteCodeURL)
end
if websiteInfo then
launch:DownloadPage(siteCodeURL, function(response, errMsg)
Expand Down
Loading