scrape v3.1.0 Scrape.Tools.URL
Simple utility functions to extract information from URLs.
Link to this section Summary
Functions
Transforms a given url into it's basic form, only including protocol scheme and host, without any other things like path, query or hash.
Checks if a given string actually represents an URL.
Rebase an URL to another root URL, useful for turning relative URLs into absolute ones.
Link to this section Functions
Link to this function
base(url)
Transforms a given url into it's basic form, only including protocol scheme and host, without any other things like path, query or hash.
Examples
iex> URL.base("https://example.com/path?param=1#search")
"https://example.com"
iex> URL.base("//example.com")
"http://example.com"
Link to this function
is_http?(url)
Checks if a given string actually represents an URL.
Example
iex> URL.is_http?("http://example.com")
true
iex> URL.is_http?("example")
false
Link to this function
merge(url, root_url)
Rebase an URL to another root URL, useful for turning relative URLs into absolute ones.
Example
iex> URL.merge("/path", "http://example.com")
"http://example.com/path"