url
The url
library contains functions related to URL processing.
get the host for the URL |
|
get the suffix of the host for the URL |
|
get the prefix for the host of the URL |
|
get the sub host for the host of the URL |
|
get number of components in the host |
|
get the URL path |
|
get the suffix of the URL path |
|
get the prefix of the URL path |
|
get the sub path of the URL path |
|
get the number of components in the URL path |
|
check if the value is a valid URL |
hostName
Get the host for the URL.
hostName(URL)
Where:
-
URL
is the URL from which to extract the host.
@library("url:", "url").
input("http://example.com/path").
result(X) :- input(Y), X = url:hostName(Y).
@output("result").
result("example.com")
suffixHostName
Get the suffix of the host for the URL.
suffixHostName(URL, Pos)
Where:
-
URL
is the URL from which to extract the suffix of the host. -
Pos
is an integer, the position of the element to retrieve from the suffix.
@library("url:", "url").
input("http://sub.example.com/path", 2).
result(X) :- input(Y, Z), X = url:suffixHostName(Y, Z).
@output("result").
result("com")
prefixHostName
Get the prefix for the host of the URL.
prefixHostName(URL, Elements)
Where:
-
URL
is the URL from which to extract the prefix of the host. -
Elements
is an integer, the number of elements to retrieve from the prefix.
@library("url:", "url").
input("http://sub.example.com/path", 1).
result(X) :- input(Y, Z), X = url:prefixHostName(Y, Z).
@output("result").
result("sub")
subHostName
Get the sub host for the host of the URL.
subHostName(URL, StartPos, EndPos)
Where:
-
URL
is the URL from which to extract the sub host. -
StartPos
is an integer, the starting position of the sub host name to extract. -
EndPos
is an integer, the ending position of the sub host name to extract.
@library("url:", "url").
input("http://sub.example.com/path", 0, 2).
result(X) :- input(Y, Z, W), X = url:subHostName(Y, Z, W).
@output("result").
result("sub.example")
hostNameSize
Get the number of components in the host.
hostNameSize(URL)
Where:
-
URL
is the URL from which to count the number of components in the host.
@library("url:", "url").
input("http://sub.example.com/path").
result(X) :- input(Y), X = url:hostNameSize(Y).
@output("result").
result(3)
path
Get the URL path.
path(URL)
Where:
-
URL
is the URL from which to extract the path.
@library("url:", "url").
input("http://example.com/path/to/resource").
result(X) :- input(Y), X = url:path(Y).
@output("result").
result("/path/to/resource")
suffixPath
Get the suffix of the URL path.
suffixPath(URL, Pos)
Where:
-
URL
is the URL from which to extract the suffix of the path. -
Pos
is an integer, the position of the element to retrieve from the suffix.
@library("url:", "url").
input("http://example.com/path/to/resource", 2).
result(X) :- input(Y, Z), X = url:suffixPath(Y, Z).
@output("result").
result("resource")
prefixPath
Get the prefix of the URL path.
prefixPath(URL, Elements)
Where:
-
URL
is the URL from which to extract the prefix of the path. -
Elements
is an integer, the number of elements to retrieve from the prefix.
@library("url:", "url").
input("http://example.com/path/to/resource", 2).
result(X) :- input(Y, Z), X = url:prefixPath(Y, Z).
@output("result").
result("path.to").
subPath
Get the sub path of the URL path.
subPath(URL, StartPos, EndPos)
Where:
-
URL
is the URL from which to extract the sub path. -
StartPos
is an integer, the starting position of the sub path to extract. -
EndPos
is an integer, the ending position of the sub path to extract.
@library("url:", "url").
input("http://example.com/path/to/resource", 1, 2).
result(X) :- input(Y, Z, W), X = url:subPath(Y, Z, W).
@output("result").
result("/to")
pathSize
Get the number of components in the URL path.
pathSize(URL)
Where:
-
URL
is the URL from which to count the number of components in the path.
@library("url:", "url").
input("http://example.com/path/to/resource").
result(X) :- input(Y), X = url:pathSize(Y).
@output("result").
result(3)