From ed574d9eb3308619fc3e735251bfd42e6cfdb8e2 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Thu, 7 Dec 2023 16:04:16 -0800 Subject: [PATCH] Anticipate another type of link Fixes #450 --- R/drive_id-class.R | 2 +- tests/testthat/test-drive_id-class.R | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/R/drive_id-class.R b/R/drive_id-class.R index 379512576..4a6163706 100644 --- a/R/drive_id-class.R +++ b/R/drive_id-class.R @@ -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) diff --git a/tests/testthat/test-drive_id-class.R b/tests/testthat/test-drive_id-class.R index 22259484f..426679334 100644 --- a/tests/testthat/test-drive_id-class.R +++ b/tests/testthat/test-drive_id-class.R @@ -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" )) )