Decode webR REPL link(s) to extract files to local directory
decode_webr_link.Rd
Decodes webR REPL sharelinks to extract the embedded files and save them to a local directory. This is the reverse operation of creating webR links. Handles both single URLs and multiple URLs automatically.
Usage
decode_webr_link(
url,
output_dir = "./webr_files",
overwrite = FALSE,
create_subdir = TRUE,
name_dirs = TRUE
)
Arguments
- url
Character string or vector containing webR REPL URL(s)
- output_dir
Character string specifying the output directory path (default: "./webr_files")
- overwrite
Logical. Whether to overwrite existing files (default: FALSE)
- create_subdir
Logical. Whether to create subdirectories. For single URLs, creates a subdirectory named after the URL hash. For multiple URLs, creates numbered subdirectories (default: TRUE)
- name_dirs
Logical. For multiple URLs only: whether to name directories by URL index rather than hash (default: TRUE). Ignored for single URLs.
Examples
if (FALSE) { # \dontrun{
# Single URL
url <- "https://webr.r-wasm.org/latest/#code=eJy1..."
result <- decode_webr_link(url)
print(result)
# Multiple URLs
urls <- c(
"https://webr.r-wasm.org/latest/#code=...",
"https://webr.r-wasm.org/v0.5.4/#code=..."
)
results <- decode_webr_link(urls)
print(results)
# Custom settings for single URL
result <- decode_webr_link(url,
output_dir = "./my_code",
create_subdir = FALSE,
overwrite = TRUE)
# Custom settings for multiple URLs
results <- decode_webr_link(urls,
output_dir = "./my_scripts",
name_dirs = FALSE) # Use hash-based names
} # }