Skip to content

Guessing the accept type from file extension #767

Description

@dmi3kno

In accept() function you guys have this check:

httr/R/headers.r

Lines 98 to 100 in 34b9565

if (substr(type, 1, 1) == ".") {
type <- mime::guess_type(type, empty = NULL)
}

I am using this function to specify the file type to be accepted using the file extension only, for example:

 httr::accept(".html")

#> Error in `type[file == ""] <- empty`:
#> ! replacement has length zero
#> Show Traceback

What was the idea when you made this if() statement? Did you guys intend to

  • check that only extension is provided OR
  • detect the hidden files (files, that start their name with a .)?

I think the function should be more clear about its intent. So far your code is checking for hidden files and not the extensions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions