RedirectMapCheck (redirect_map_check v1.0.0)

Copy Markdown View Source

Check a redirect map given as a CSV with the columns from_path and to_path.

Both cells are trimmed and then compared exactly as strings: case and a trailing slash are significant, so /Pricing and /pricing/ are different paths. The tool never fetches a URL and cannot know a final status code; it only reads the map you give it.

Checks:

  • self redirects (from equals to). They are reported on their own and are left out of the chain and loop checks.
  • duplicates: a source listed more than once with the same target.
  • conflicts: a source listed with more than one different target. The target of the first row is the one used for the chain and loop checks.
  • chains: a source whose target is itself a source. One line per chain start (a source that no other source points at) with the hops and the final target.
  • loops: a cycle among two or more sources, each loop listed once.

Walks use a visited set and stop after 100 hops, so long chains and loops never recurse without end.

Summary

Functions

Analyse the rows. Returns a map with :rows, :sources, :self, :duplicates, :conflicts, :chains and :loops.

The hop limit for a chain walk.

Parse the CSV text into a list of rows.

Render the report as text.

True when --strict should fail: a self redirect, conflict, chain or loop exists.

Types

row()

@type row() :: %{from: String.t(), to: String.t(), row: pos_integer()}

Functions

analyze(rows)

Analyse the rows. Returns a map with :rows, :sources, :self, :duplicates, :conflicts, :chains and :loops.

max_hops()

The hop limit for a chain walk.

parse(text)

@spec parse(String.t()) :: {:ok, [row()]} | {:error, String.t()}

Parse the CSV text into a list of rows.

render(a)

Render the report as text.

strict_problems?(a)

True when --strict should fail: a self redirect, conflict, chain or loop exists.