Skip to content

Commit b1310e9

Browse files
committed
don't check extensions only, since some services don't provide a direct link to a file with an extension
1 parent 27fdb2e commit b1310e9

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

lua/pac3/editor/client/saved_parts.lua

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,32 +213,25 @@ function pace.LoadParts(name, clear, override_part)
213213
pac.dprint("loading Parts %s", name)
214214

215215
if name:find("https?://") then
216+
local function callback(str)
217+
if string.find( str, "<!DOCTYPE html>" ) then
218+
pace.MessagePrompt("Invalid URL, .txt expected, but the website returned a HTML file. If you're using Github then use the RAW option.", "URL Failed", "OK")
219+
return
220+
end
216221

217-
local ext = name:match("/.+%.(%a+)[%?&]?.-")
218-
if ext == "txt" then
219-
local function callback(str)
220-
if string.find( str, "<!DOCTYPE html>" ) then
221-
pace.MessagePrompt("Invalid URL, the website returned a HTML file. If you're using Github then use the RAW option.", "URL Failed", "OK")
222-
return
223-
end
224-
225-
local data, err = pace.luadata.Decode(str)
226-
if not data then
227-
local message = string.format("URL fail: %s : %s\n", name, err)
228-
pace.MessagePrompt(message, "URL Failed", "OK")
229-
return
230-
end
231-
232-
pace.LoadPartsFromTable(data, clear, override_part)
222+
local data, err = pace.luadata.Decode(str)
223+
if not data then
224+
local message = string.format("Failed to load pac3 outfit from url: %s : %s\n", name, err)
225+
pace.MessagePrompt(message, "URL Failed", "OK")
226+
return
233227
end
234228

235-
pac.HTTPGet(name, callback, function(err)
236-
pace.MessagePrompt(err, "HTTP Request Failed for " .. name, "OK")
237-
end)
238-
else
239-
pace.MessagePrompt(".txt file expected, got" .. ext, "Invalid file", "OK")
240-
return
229+
pace.LoadPartsFromTable(data, clear, override_part)
241230
end
231+
232+
pac.HTTPGet(name, callback, function(err)
233+
pace.MessagePrompt(err, "HTTP Request Failed for " .. name, "OK")
234+
end)
242235
else
243236
name = name:gsub("%.txt", "")
244237

0 commit comments

Comments
 (0)