fuzzyurl v1.0.1 Fuzzyurl.Match

Link to this section Summary

Functions

From a list of Fuzzyurl masks, returns the list index of the one which best matches url. Returns nil if none of masks match

Returns 0 for wildcard match, 1 for exact match, or nil otherwise

Returns an integer representing how closely mask (which may have wildcards) resembles url (which may not), or nil in the case of a conflict

Returns a Fuzzyurl struct containing values representing how well different parts of mask and url match. Values are integer; higher values indicate closer matches

Returns true if mask (which may contain wildcards) matches url (which may not), or false otherwise

Link to this section Functions

Link to this function best_match_index(masks, url)

From a list of Fuzzyurl masks, returns the list index of the one which best matches url. Returns nil if none of masks match.

iex> masks = [Fuzzyurl.mask(path: "/foo/*"), Fuzzyurl.mask(path: "/foo/bar"), Fuzzyurl.mask]
iex> Fuzzyurl.Match.best_match_index(masks, Fuzzyurl.from_string("http://exmaple.com/foo/bar"))
1
Link to this function fuzzy_match(mask, value)
fuzzy_match(String.t(), String.t()) :: 0 | 1 | nil

Returns 0 for wildcard match, 1 for exact match, or nil otherwise.

Wildcard language:

*              matches anything
foo/*          matches "foo/" and "foo/bar/baz" but not "foo"
foo/**         matches "foo/" and "foo/bar/baz" and "foo"
*.example.com  matches "api.v1.example.com" but not "example.com"
**.example.com matches "api.v1.example.com" and "example.com"

Any other form is treated as a literal match.

Link to this function match(mask, url)
match(
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  },
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  }
) :: non_neg_integer() | nil

Returns an integer representing how closely mask (which may have wildcards) resembles url (which may not), or nil in the case of a conflict.

Link to this function match_scores(mask, url)
match_scores(
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  },
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  }
) :: %Fuzzyurl{
  fragment: term(),
  hostname: term(),
  password: term(),
  path: term(),
  port: term(),
  protocol: term(),
  query: term(),
  username: term()
}

Returns a Fuzzyurl struct containing values representing how well different parts of mask and url match. Values are integer; higher values indicate closer matches.

Link to this function matches?(mask, url)
matches?(
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  },
  %Fuzzyurl{
    fragment: term(),
    hostname: term(),
    password: term(),
    path: term(),
    port: term(),
    protocol: term(),
    query: term(),
    username: term()
  }
) :: boolean()

Returns true if mask (which may contain wildcards) matches url (which may not), or false otherwise.