Skip to contents

Resolves a character vector through declared `rel=canonical` folds. This is distinct from URL syntax canonicalization; inputs are expected to already be in the same URL namespace as the canonical table.

Usage

resolve_canonical_urls(
  urls,
  canonicals_df,
  canonical_from_col = "from",
  canonical_to_col = "to",
  canonical_duplicate_from_policy = c("strict", "first_wins", "last_wins",
    "most_frequent", "prune_source", "resolve_if_consistent"),
  canonical_loop_handling = c("error", "prune_loop", "break_arrow")
)

Arguments

urls

Character vector of URLs to resolve.

canonicals_df

A data frame of declared canonical links.

canonical_from_col, canonical_to_col

From/to columns in `canonicals_df`.

canonical_duplicate_from_policy

How to handle a canonical source with multiple distinct targets. See [build_fold_map()].

canonical_loop_handling

How to handle canonical cycles. See [build_fold_map()].

Value

A data frame with `original`, `resolved`, `changed`, and `signal` columns. The applied fold map is attached as attribute `"fold_map"`.

Examples

canonicals <- data.frame(
  from = c("A", "B"),
  to = c("B", "C")
)
resolve_canonical_urls(c("A", "B", "X"), canonicals)
#>   original resolved changed    signal
#> 1        A        C    TRUE canonical
#> 2        B        C    TRUE canonical
#> 3        X        X   FALSE      <NA>