Euros v0.2.1 Euros.URI View Source

Provides the function for parse uri

Link to this section Summary

Functions

Check path relative or absolute

Check url relative or absolute

Check uri to same host for relative uri

Parse url and return base_uri Delete path, query and fragment from url

Link to this section Functions

Link to this function absolute_path(href_path, request_path) View Source

Check path relative or absolute

Examples

iex> Euros.URI.absolute_path("path?query=foo#fragment", "/relative_path/index")
"/relative_path/path?query=foo#fragment"
iex> Euros.URI.absolute_path("/path?query=foo#fragment", "/")
"/path?query=foo#fragment"

Check url relative or absolute

Examples

iex> Euros.URI.is_relative_url(URI.parse("/path?query=foo#fragment"))
true
iex> Euros.URI.is_relative_url(URI.parse("http://example.com/path?query=foo#fragment"))
false
Link to this function is_same_host(href_uri, base_uri) View Source

Check uri to same host for relative uri

Examples

iex> href_uri = URI.parse("/path?query=foo#fragment")
%URI{authority: nil, fragment: "fragment", host: nil, path: "/path", port: nil,
 query: "query=foo", scheme: nil, userinfo: nil}
iex> base_uri = URI.parse("http://example.com")
%URI{authority: "example.com", fragment: nil, host: "example.com",
 path: nil, port: 80, query: nil, scheme: "http", userinfo: nil}
iex>  Euro.URI.is_same_host(href_uri, base_uri)

Parse url and return base_uri Delete path, query and fragment from url

Examples

iex>  Euro.URI.base_uri("http://example.com/path?query=foo#fragment")
%URI{authority: "example.com", fragment: nil,
 host: "example.com", path: nil, port: 80, query: nil,
 scheme: "http", userinfo: nil}