From e9482f67ee0ae725ec8110f7f082bf32a6962806 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Tue, 2 May 2023 16:21:10 -0700 Subject: [PATCH] do not transform self github links to local links This buys me some time to make sure https://github.com/carpentries/sandpaper/pull/447 will not break a lot of things. --- librarycarpentry/lc-data-intro.R | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/librarycarpentry/lc-data-intro.R b/librarycarpentry/lc-data-intro.R index 46da478..6a63a29 100644 --- a/librarycarpentry/lc-data-intro.R +++ b/librarycarpentry/lc-data-intro.R @@ -48,16 +48,11 @@ that <- "/librarycarpentry/lc-data-intro/blob/gh-pages/" to_fix <- startsWith(tolower(lnks$path), this) | startsWith(tolower(lnks$path), that) purrr::walk(lnks$node[to_fix], function(node) { dst <- xml2::xml_attr(node, "destination") - new <- sub(paste0("https://github.com", this), "", dst, ignore.case = TRUE) - new <- sub(paste0("https://github.com", that), "", new, ignore.case = TRUE) - if (startsWith(new, "files")) { - xml2::xml_set_attr(node, "destination", paste0("../episodes/", new)) - if (new == "files") { - xml2::xml_set_text(node, "episodes/files") - } - } else { - xml2::xml_set_attr(node, "destination", new) + new <- sub("gh-pages", "main", dst) + if (endsWith(new, "files")) { + xml2::xml_set_text(node, "episodes/files") } + xml2::xml_set_attr(node, "destination", new) }) all_fix <- to_fix | all_fix