Skip to content

Commit

Permalink
🔪 simplify code, just call file_ext instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Patrick Kyle committed Mar 5, 2019
1 parent 37bf706 commit 0f2e084
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,14 @@ get_package_mapping <- function(script_name, url_package, dependencies) {
}

get_mimetype <- function(filename) {
# the next two lines are borrowed from file_ext
last_dot_pos <- regexpr("\\.([[:alnum:]]+)$", filename)
file_ext <- ifelse(last_dot_pos > -1L,
substring(filename,
last_dot_pos + 1L),
"")
# the tools package is available to all
filename_ext <- tools::file_ext(filename)

if (file_ext == 'js')
if (filename_ext == 'js')
return('application/JavaScript')
else if (file_ext == 'css')
else if (filename_ext == 'css')
return('text/css')
else if (file_ext == 'map')
else if (filename_ext == 'map')
return('application/json')
else
return(NULL)
Expand Down

0 comments on commit 0f2e084

Please sign in to comment.