Skip to content

Commit

Permalink
replace URLdecode() with url_unescape() etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
HenningLorenzen-ext-bayer committed Jul 12, 2024
1 parent ea73a3c commit cb57136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions R/check-built.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ check_missing_images <- function(pkg, src_path, dst_path) {
img <- xml2::xml_find_all(html, ".//img")
src <- xml2::xml_attr(img, "src")

rel_src <-
purrr::map_chr(.x = src[xml2::url_parse(src)$scheme == ""],
.f = utils::URLdecode)
rel_src <- xml2::url_unescape(src[xml2::url_parse(src)$scheme == ""])
rel_path <- path_norm(path(path_dir(dst_path), rel_src))
exists <- file_exists(path(pkg$dst_path, rel_path))

Expand Down
12 changes: 3 additions & 9 deletions R/tweak-page.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,10 @@ tweak_rmarkdown_html <- function(html, input_path, pkg = list(bs_version = 3)) {
abs_src <- is_absolute_path(src)
if (any(abs_src)) {
img_target_nodes <- img[abs_src]

img_src_real <-
purrr::map_chr(.x = src[abs_src], .f = utils::URLdecode)
img_src_real <- path_real(img_src_real)

input_path_real <- path_real(utils::URLdecode(input_path))

img_src_real <- path_real(xml2::url_unescape(src[abs_src]))
input_path_real <- path_real(xml2::url_unescape(input_path))
img_rel_paths <- path_rel(path = img_src_real, start = input_path_real)
img_rel_paths <-
purrr::map_chr(.x = img_rel_paths, .f = utils::URLencode)
img_rel_paths <- xml2::url_escape(img_rel_paths)

purrr::walk2(
.x = img_target_nodes,
Expand Down

0 comments on commit cb57136

Please sign in to comment.