Difference between revisions of "Http.checkURL"

From ComputerCraft Wiki
Jump to: navigation, search
(Add http.checkURL page)
(No difference)

Revision as of 19:59, 1 August 2015


Grid Redstone.png  Function http.checkURL
Validates a URL, checking it is in the correct format and it the website is on the whitelist. If the URL is not valid then the second return value will be an appropriate error message.
Syntax http.checkURL(string url)
Returns boolean success, string message
Part of ComputerCraft
API HTTP

Examples

Grid paper.png  Example
Validates a URL and errors if it is invalid.
Code
local success, message = http.checkURL("http://example.com")
if not success then
  error("Invalid URL: " .. message)
end



Grid paper.png  Example
Various outputs of http.checkURL.
Code
http.checkURL("http://example.com") -- true
http.checkURL("example.com") -- false, URL malformed
http.checkURL("ftp://example.com") -- false, URL not http