View Source Crawler.Linker.PathBuilder (Crawler v1.5.0)

Builds a path for a link (can be a URL itself or a relative link) based on the input string which is a URL with or without its protocol.

Summary

Functions

Builds a path for a link (can be a URL itself or a relative link) based on the input string which is a URL with or without its protocol.

Functions

Link to this function

build_path(current_url, link, safe \\ true)

View Source

Builds a path for a link (can be a URL itself or a relative link) based on the input string which is a URL with or without its protocol.

Examples

iex> PathBuilder.build_path(
iex>   "https://cool.beans:7777/dir/page1",
iex>   "https://hello.world:8888/remote/page2"
iex> )
"hello.world-8888/remote/page2"

iex> PathBuilder.build_path(
iex>   "https://cool.beans:7777/dir/page1",
iex>   "local/page2"
iex> )
"cool.beans-7777/dir/local/page2"

iex> PathBuilder.build_path(
iex>   "https://cool.beans:7777/dir/page1",
iex>   "/local/page2"
iex> )
"cool.beans-7777/local/page2"

iex> PathBuilder.build_path(
iex>   "https://cool.beans:7777/parent/dir/page1",
iex>   "../local/page2"
iex> )
"cool.beans-7777/parent/local/page2"

iex> PathBuilder.build_path(
iex>   "https://cool.beans:7777/parent/dir/page1",
iex>   "../../local/page2"
iex> )
"cool.beans-7777/local/page2"