Combo.URLBuilder (combo v0.10.0)

View Source

Builds url or path.

Summary

Functions

Builds a path with relevant script name.

Builds the integrity hash to a static asset given its file path.

Builds the path to a static asset given its file path.

Builds the url to a static asset given its file path.

Functions

guarded_static_integrity(endpoint, path)

guarded_static_url(endpoint, path)

path(endpoint_or_conn_or_socket, router, path, params \\ %{})

Builds a path with relevant script name.

Examples

iex> path(conn, MyApp.Web.Router, "/posts")
"/posts"

iex> path(conn, MyApp.Web.Router, "/posts", page: 1)
"/posts?page=1"

static_integrity(endpoint_or_conn_or_socket, path)

Builds the integrity hash to a static asset given its file path.

See Combo.Endpoint.static_integrity/1 for more information.

Examples

iex> static_integrity(conn, "/assets/js/app.js")
"813dfe33b5c7f8388bccaaa38eec8382"

iex> static_integrity(socket, "/assets/js/app.js")
"813dfe33b5c7f8388bccaaa38eec8382"

iex> static_integrity(MyApp.Web.Endpoint, "/assets/js/app.js")
"813dfe33b5c7f8388bccaaa38eec8382"

static_path(endpoint_or_conn_or_socket, path)

Builds the path to a static asset given its file path.

See Combo.Endpoint.static_path/1 for more information.

Examples

iex> static_path(conn, "/assets/js/app.js")
"/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

iex> static_path(socket, "assets/js/app.js")
"/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

iex> static_path(MyApp.Web.Endpoint, "assets/js/app.js")
"/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

static_url(endpoint_or_conn_or_socket, path)

Builds the url to a static asset given its file path.

See Combo.Endpoint.static_url/0 and Combo.Endpoint.static_path/1 for more information.

Examples

iex> static_url(conn, "/assets/js/app.js")
"https://example.com/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

iex> static_url(socket, "/assets/js/app.js")
"https://example.com/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

iex> static_url(MyApp.Web.Endpoint, "/assets/js/app.js")
"https://example.com/assets/js/app-813dfe33b5c7f8388bccaaa38eec8382.js"

url(endpoint_or_conn_or_socket, path, params \\ %{})

Builds an url.

Examples

iex> url(conn, "/posts")
"https://example.com/posts"

iex> url(conn, "/posts", page: 1)
"https://example.com/posts?page=1"