Skip to content

Commit

Permalink
Merge pull request #150 from thisisnic/fix-quoted-input
Browse files Browse the repository at this point in the history
Fix #149
  • Loading branch information
chainsawriot authored Dec 30, 2023
2 parents 0c8d246 + 6f48ce7 commit ef54b1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ auth_setup <- function(instance = NULL, type = NULL, name = NULL, path = NULL, c
while (is.null(instance) || instance == "") {
instance <- rtoot_ask(prompt = "On which instance do you want to authenticate (e.g., \"mastodon.social\")? ", pass = FALSE)
}
if(quoted_string(instance)){
instance <- substr(instance, 2, nchar(instance)-1)
}
client <- get_client(instance = instance)
if (!isTRUE(type %in% c("public", "user"))) {
type <- c("public", "user")[rtoot_menu(choices = c("public", "user"), title = "What type of token do you want?", verbose = TRUE)]
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,8 @@ break_process_request <- function(api_response, retryonratelimit = FALSE, verbos
}
return(FALSE)
}

## a function to determine if input to readline has been quoted or not
quoted_string <- function(x){
(grepl("^\"", x) && grepl("\"$", x)) || (grepl("^'", x) && grepl("'$", x))
}

0 comments on commit ef54b1a

Please sign in to comment.