dont crash on bad input

This commit is contained in:
sevenrats 2023-10-15 19:40:09 -04:00
parent 8f8650fd69
commit 1e035337de

View File

@ -193,6 +193,7 @@ function inferServerUrl(url as string) as string
end for
handled = 0
timeout = CreateObject("roTimespan")
if hosts.count() > 0
while timeout.totalseconds() < 15
resp = wait(0, port)
if type(resp) = "roUrlEvent"
@ -212,6 +213,7 @@ function inferServerUrl(url as string) as string
end if
end while
print "inferServerUrl in utils/misc.brs failed to find a server from the string " url " because it timed out."
end if
return ""
end function
@ -225,6 +227,8 @@ function urlCandidates(input as string)
' a proto wasn't declared
url = parseUrl("none://" + input)
end if
' if the proto is still invalid then the string is not valid
if url[1] = invalid then return []
proto = url[1]
host = url[2]
port = url[3]