diff --git a/R/compression.R b/R/compression.R index f8ddeb3..f65fc3f 100644 --- a/R/compression.R +++ b/R/compression.R @@ -1,11 +1,11 @@ find_compress <- function(f) { - if (grepl("zip$", f)) { + if (grepl("\\.zip$", f)) { return(list(file = sub("\\.zip$", "", f), compress = "zip")) } - if (grepl("tar\\.gz$", f)) { + if (grepl("\\.tar\\.gz$", f)) { return(list(file = sub("\\.tar\\.gz$", "", f), compress = "tar")) } - if (grepl("tar$", f)) { + if (grepl("\\.tar$", f)) { return(list(file = sub("\\.tar$", "", f), compress = "tar")) } return(list(file = f, compress = NA_character_)) diff --git a/tests/testthat/test_compress.R b/tests/testthat/test_compress.R index 2537f93..21e98b2 100644 --- a/tests/testthat/test_compress.R +++ b/tests/testthat/test_compress.R @@ -6,6 +6,8 @@ test_that("Recognize compressed file types", { expect_true(rio:::find_compress("file.tar.gz")$compress == "tar") expect_true(is.na(rio:::find_compress("file.gz")$compress)) expect_true(is.na(rio:::find_compress("file.notcompressed")$compress)) + ## #395 + expect_true(is.na(rio:::find_compress("file.gzip")$compress)) ## NA for now }) test_that("Export to compressed (zip) / import", {