Resolve URLs through rel=canonical declarations
Source:R/resolve_canonicals.R
resolve_canonical_urls.RdResolves 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.
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>