Skip to content

Commit

Permalink
fix: improve on pattern by using ] as first element
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Oct 24, 2024
1 parent 91f2576 commit 76ef423
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ make_c_call <- function(choices) {
#'
#' @keywords internal
sanitize_id <- function(id) {
escape_characters <- " !\"#$%&'()*+,./:;<=>?@[\\]^`{|}~"
pattern <- paste(
sep = "", collapse = "|", "\\", strsplit(escape_characters, "")[[1]]
)
pattern <- gsub("\\<", "<", pattern, fixed = TRUE)
pattern <- gsub("\\>", ">", pattern, fixed = TRUE)
# Left square bracket needs to be first in the pattern to avoid errors with pattern
pattern_escape <- "[] !\"#$%&'()*+,./:;<=>?@[\\^`{|}~]"

id_new <- gsub(pattern, "_", id)
id_new <- gsub(pattern_escape, "_", id)
hashes <- vapply(
id[id != id_new],
rlang::hash, character(1),
Expand Down

0 comments on commit 76ef423

Please sign in to comment.