View source: R/audit_redirects.R
| audit_redirects | R Documentation |
Analyzes a redirect data frame and returns a diagnostic report
covering chain lengths, loops, conflicting sources, self-referencing
redirects, and terminal destinations. Useful as a pre-flight check before
running resolve_redirects or pagerank.
audit_redirects(
redirects_df,
edge_list_df = NULL,
redirect_from_col = "from",
redirect_to_col = "to",
edge_from_col = "from",
edge_to_col = "to"
)
redirects_df |
A data frame containing redirect rules. |
edge_list_df |
Optional data frame of edges. If provided, orphaned redirects (rules whose source URL does not appear in the edge list) are identified. |
redirect_from_col |
Character, name of the source column in
|
redirect_to_col |
Character, name of the target column in
|
edge_from_col |
Character, name of the source column in
|
edge_to_col |
Character, name of the target column in
|
A list with class "redirect_audit" containing:
Total number of redirect rules (after NA removal).
Number of self-referencing redirects (from == to).
Data frame of self-referencing redirects.
Number of source URLs with conflicting targets.
Data frame listing each conflicting source and its distinct targets.
Number of redirect loops detected.
List of character vectors, each describing a cycle path.
Data frame with columns from, to_final, and
chain_length showing the terminal destination and hop count
for every source URL.
Maximum chain length found.
Data frame of redirect sources not found in
the edge list (only when edge_list_df is provided).
redirects <- data.frame(
from = c("A", "B", "C", "D", "D", "E"),
to = c("B", "C", "final", "X", "Y", "E")
)
audit <- audit_redirects(redirects)
print(audit)
# With an edge list to detect orphaned redirects
edges <- data.frame(from = "Z", to = "A")
audit2 <- audit_redirects(redirects, edge_list_df = edges)
audit2$orphaned_redirects
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.