R/is_url_valid.R

Defines functions is_url_valid

Documented in is_url_valid

#' Is the download URL valid?
#'
#' The download link expires after 4 hours.
#' @inheritParams default_params_doc
#' @export
is_url_valid <- function(
  download_url = get_tmhmm_url()
) {
  url <- download_url
  local_path <- tempfile()
  is_valid <- FALSE
  tryCatch({
      suppressWarnings(
        utils::download.file(
          url = url,
          destfile = local_path,
          quiet = TRUE
        )
      )
      is_valid <- TRUE
      file.remove(local_path)
    },
    error = function(e) {} # nolint ignore error
  )
  is_valid
}

Try the tmhmm package in your browser

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

tmhmm documentation built on Nov. 18, 2020, 9:07 a.m.