Normalise the URLs in a list of search results and show what is duplicated.
Input is a CSV with the columns query and url. Extra columns are ignored. The query is
trimmed and compared exactly (case counts). Every URL is normalised with these rules:
- trimmed
- scheme and host lowercased
httptreated ashttps- a leading
www.removed from the host - the fragment (everything from
#) removed - query parameters whose name starts with
utm_(any letter case) removed, all others kept in their order - trailing slashes removed from the path unless the path is just
/
The tool reads the file you give it. It fetches nothing and has no network access.
Summary
Functions
Analyse parsed rows (URLs already normalised). Returns a map with :rows, :unique,
:duplicates, :multi_total, :multi (URLs returned by more than one query, most queries
first, each {url, [queries]}), :hosts and :queries.
Normalise one URL. Returns {:ok, url} or {:error, reason}.
Parse CSV text into rows. Returns {:ok, rows} or {:error, message}.
Format a percentage with one decimal.
Render the analysis as text.
Types
@type row() :: %{line: pos_integer(), query: String.t(), url: String.t()}
Functions
Analyse parsed rows (URLs already normalised). Returns a map with :rows, :unique,
:duplicates, :multi_total, :multi (URLs returned by more than one query, most queries
first, each {url, [queries]}), :hosts and :queries.
Normalise one URL. Returns {:ok, url} or {:error, reason}.
Parse CSV text into rows. Returns {:ok, rows} or {:error, message}.
Format a percentage with one decimal.
Render the analysis as text.