Skip to content

Commit

Permalink
fix rstudio/pagedown#329: provide a fallback favicon.ico
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 29, 2024
1 parent 9a39d1e commit e8a26b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: servr
Type: Package
Title: A Simple HTTP Server to Serve Static Files or Dynamic Documents
Version: 0.30.1
Version: 0.30.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Carson", "Sievert", role = "ctb"),
Expand Down Expand Up @@ -31,4 +31,4 @@ License: GPL
URL: https://github.com/yihui/servr
BugReports: https://github.com/yihui/servr/issues
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN servr VERSION 0.31

- A fallback `favicon.ico` will be provided if it does not exist when serving files (thanks, @MMJansen, rstudio/pagedown#329).

# CHANGES IN servr VERSION 0.30

Expand Down
5 changes: 4 additions & 1 deletion R/static.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ serve_dir = function(dir = '.', response = NULL) function(req) {
# because it will be treated as /foo/bar/404.html; if 404.html contains
# paths like ./css/style.css, I don't know how to let the browser know that
# it means /css/style.css instead of /foo/bar/css/style.css
if (!file.exists(path)) return(if (try_404(path)) list(
if (!file.exists(path)) return(if (path == './favicon.ico') list(
status = 200L, body = xfun::read_bin(file.path(R.home('doc'), 'html', 'favicon.ico')),
headers = list('Content-Type' = 'image/x-icon')
) else if (try_404(path)) list(
status = 302L, body = '', headers = list('Location' = '/404.html')
) else list(
status = 404L, headers = list('Content-Type' = 'text/plain'),
Expand Down

0 comments on commit e8a26b8

Please sign in to comment.