http.checkURL

From ComputerCraft Wiki
Jump to: navigation, search


Grid Redstone.png  Function http.checkURL
Validates a URL, checking it is in the correct format and the website is on the HTTP 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