Module jls.net.URL
Represents an URL.
Class URL
URL:new (protocol[, host[, port[, file]]]) | Creates a new URL. |
url:getProtocol () | Returns this URL scheme. |
url:getUserInfo () | Returns this URL userInfo. |
url:getHost () | Returns this URL hostname. |
url:getPort () | Returns this URL port. |
url:getPath () | Returns this URL path. |
url:getQuery () | Returns this URL query. |
url:toString () | Returns the string value representing this URL. |
URL.parse (sUrl) | Returns the URL corresponding to the specified string. |
URL.fromString (sUrl) | Returns the URL corresponding to the specified string. |
URL.format (tUrl) | Returns the string value representing the specified URL. |
Class URL
The URL class represents an Uniform Resource Locator.
see https://tools.ietf.org/html/rfc1738
- URL:new (protocol[, host[, port[, file]]])
-
Creates a new URL.
Parameters:
- protocol The protocol or the URL as a string or the URL as a table.
- host string The host name. (optional)
- port string The port number. (optional)
- file string The file part of the URL. (optional)
Returns:
-
a new URL
Usage:
local url = URL:new('http://somehost:1234/some/path') url:getHost() -- returns "somehost"
- url:getProtocol ()
-
Returns this URL scheme.
Returns:
-
this URL scheme.
- url:getUserInfo ()
-
Returns this URL userInfo.
Returns:
-
this URL userInfo.
- url:getHost ()
-
Returns this URL hostname.
Returns:
-
this URL hostname.
- url:getPort ()
-
Returns this URL port.
Returns:
-
this URL port.
- url:getPath ()
-
Returns this URL path.
Returns:
-
this URL path.
- url:getQuery ()
-
Returns this URL query.
Returns:
-
this URL query.
- url:toString ()
-
Returns the string value representing this URL.
Returns:
-
the string value representing this URL.
- URL.parse (sUrl)
-
Returns the URL corresponding to the specified string.
The table contains the keys: scheme, host, port, path, query, userinfo, username, password.
Parameters:
- sUrl string The string to parse.
Returns:
-
table
a table representing the URL or nil.
- URL.fromString (sUrl)
-
Returns the URL corresponding to the specified string.
Parameters:
- sUrl string The URL as a string.
Returns:
-
jls.net.URL
the URL or nil.
- URL.format (tUrl)
-
Returns the string value representing the specified URL.
Parameters:
- tUrl table The URL as a table.
Returns:
-
the string value representing the URL.