net.urlparse(url)
Parse a URL into 4 components, corresponding to the structure of a URL : scheme
://hostname
/path
?parameters
Parameters
url
A string representing a URL to parse, for example "https://www.luart.org/index.html".
Return value
Returns 4 strings, representing the scheme, the hostname, the path, and the parameters fields of the URL.If any component is not found, returns a nil value instead of a string.
If the string cannot be parsed, returns false.
Example
local net = require "net"
local console = require "console"
local url = console.readln('Enter a URL : ')
local scheme, hostname, path, parameters = net.urlparse(url)
scheme = scheme or error("The URL entered is invalid")
print("scheme :", scheme)
print("hostname :", hostname)
print("path\t:", path)
print("parameters :", parameters)