Skip to content

Commit

Permalink
Fix #395
Browse files Browse the repository at this point in the history
It won't solve the larger issue, but it makes the detection slightly
more robust.
  • Loading branch information
chainsawriot committed Apr 27, 2024
1 parent 2fb1373 commit 522faae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 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_))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test_compress.R
Expand Up @@ -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", {
Expand Down

0 comments on commit 522faae

Please sign in to comment.