Skip to content

Commit

Permalink
Partial fix for yonghah#41: Add special check for proper encoding of …
Browse files Browse the repository at this point in the history
…a URL in esriUrlValidType if an 'Invalid URL' message is returned by the server.
  • Loading branch information
jacpete committed Jan 12, 2022
1 parent 202f5b8 commit f914d68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/esriUrl.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ esriUrl_isValidType <- function(url, type = c(NA_character_, "Root", "Folder", "
} else if (!is.na(rvest::html_element(rvest::read_html(url), 'div.restErrors'))) {
reason <- sub("^[[:space:]]*", "", rvest::html_text(rvest::html_element(rvest::read_html(url), 'div.restErrors')))
out <- FALSE
if (reason == "Invalid URL") {
url_encoded <- utils::URLencode(url)
if (is.na(rvest::html_element(rvest::read_html(url_encoded), 'div.restErrors'))) {
reason <- "Invalid URL: Check encoding of supplied URL."
}
}
} else {
out <- TRUE
}
Expand Down

0 comments on commit f914d68

Please sign in to comment.