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

Update get_url() to return NA when URL name is not recognized #17

Open
allenbaron opened this issue Aug 17, 2023 · 0 comments
Open

Update get_url() to return NA when URL name is not recognized #17

allenbaron opened this issue Aug 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@allenbaron
Copy link
Collaborator

Using unrecognized names for URLs produces unusable hyperlinks in build_hyperlink().

build_hyperlink(x = "value", url = "blah", as = "gs", txt = "blah:value")
#> <googlesheets4_formula[1]>
#> [1] =HYPERLINK("blahvalue", "blah:value")

Created on 2023-08-17 by the reprex package (v2.0.1)

The function responsible for identifying URL names is get_url() which currently errors when unrecognized URL names are given to it. To allow URLs to be append to as is and from names at the same time, append_to_url() ignores errors and assumes the pass through text is the URL to append to (not always the case, above).

DO.utils/R/append.R

Lines 113 to 119 in 64d8b7c

url <- purrr::map_chr(
url,
~ tryCatch(get_url(.x), error = function(e) .x)
)
} else {
url <- tryCatch(get_url(url), error = function(e) url)
}

Identification of URLs by name should be consolidated to get_url() and return NA when input is not recognized. append_to_url() can then determine if the input matches a standard URL regex or was an unrecognized.

It might be a good idea to add an argument to get_url() to specify how to handle non-matches (error, return NA, etc.).

@allenbaron allenbaron added the bug Something isn't working label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant