Skip to content

Commit

Permalink
Anticipate another type of link
Browse files Browse the repository at this point in the history
Fixes #450
  • Loading branch information
jennybc committed Dec 8, 2023
1 parent 74a69a3 commit ed574d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/drive_id-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pillar_shaft.drive_id <- function(x, ...) {
## /d/FILE_ID Drive file
## /folders/FILE_ID Drive folder
## id=FILE_ID uploaded blob
id_regexp <- "(/d/|/folders/|id=)[^/]+"
id_regexp <- "(/d/|/folders/|id=)[^/?]+"

is_drive_url <- function(x) grepl("^http", x) & grepl(id_regexp, x)

Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-drive_id-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ test_that("as_id() extracts ids from Drive URLs but not other URLs", {
x <- c(
"https://docs.google.com/document/d/doc12345/edit",
"https://drive.google.com/drive/folders/folder12345",
# https://github.com/tidyverse/googledrive/issues/450
"https://drive.google.com/drive/folders/folder12345?usp=drive_link",
"https://drive.google.com/open?id=blob12345",
"https://docs.google.com/a/example.com/spreadsheets/d/team12345",
## Team Drive URL
# Team Drive URL
"https://drive.google.com/drive/u/0/folders/teamdrive12345"
)
expect_identical(
as_id(x),
as_id(c(
"doc12345", "folder12345", "blob12345",
"doc12345", "folder12345", "folder12345", "blob12345",
"team12345", "teamdrive12345"
))
)
Expand Down

0 comments on commit ed574d9

Please sign in to comment.