R/testthat-helpers.R

Defines functions valid_url

# Source https://stackoverflow.com/questions/52911812/check-if-url-exists-in-r
valid_url <- function(url_in, t = 2) {
  con <- url(url_in)
  check <- suppressWarnings(
    try(open.connection(con, open = "rt", timeout = t), silent = TRUE)[1]
  )
  suppressWarnings(try(close.connection(con), silent = TRUE))
  ifelse(is.null(check), TRUE, FALSE)
}

Try the hubUtils package in your browser

Any scripts or data that you put into this service are public.

hubUtils documentation built on Sept. 18, 2024, 5:09 p.m.