Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if file is available at a url #2

Open
NewGraphEnvironment opened this issue Feb 22, 2024 · 0 comments
Open

check if file is available at a url #2

NewGraphEnvironment opened this issue Feb 22, 2024 · 0 comments

Comments

@NewGraphEnvironment
Copy link
Owner

NewGraphEnvironment commented Feb 22, 2024

need to see how we can give informative error messages if url is incorrectly entered or if there are no files at the urls we are trying to hit

here is a true false start


is_valid_url <- function(url) {
  # Regular expression for a simple URL validation
  pattern <- "^https?://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,}(/\\S*)?$"
  grepl(pattern, url)
}

is_accessible_url <- function(url) {
  response <- httr::HEAD(url)
  status <- httr::status_code(response)
  status == 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant