Skip to content

Commit

Permalink
allow BugReports to be an email
Browse files Browse the repository at this point in the history
fixes #2275
  • Loading branch information
catalamarti committed Aug 15, 2024
1 parent 1d40a80 commit ca04c6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/build-home-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,13 @@ data_home_sidebar_links <- function(pkg = ".") {
repo <- cran_link(pkg$package)
links <- config_pluck(pkg, "home.links")

bug_reports <- pkg$desc$get_field("BugReports", default = NULL)
if (grepl("@", bug_reports)) bug_reports <- paste0("mailto:", bug_reports)

links <- c(
link_url(sprintf(tr_("View on %s"), repo$repo), repo$url),
link_url(tr_("Browse source code"), repo_home(pkg)),
link_url(tr_("Report a bug"), pkg$desc$get_field("BugReports", default = NULL)),
link_url(tr_("Report a bug"), bug_reports),
purrr::map_chr(links, ~ link_url(.$text, .$href))
)

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-build-home-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ test_that("cran_unquote works", {
"Quoting is CRAN's thing."
)
})

test_that("allow email in BugReports", {
# currently desc throws a warning if BugReports is an email
pkg <- local_pkgdown_site(desc = list(BugReports = "[email protected]"))
html <- xml2::read_html(data_home_sidebar(pkg))
expect_snapshot(xpath_xml(html, ".//li/a"))
})

0 comments on commit ca04c6b

Please sign in to comment.