Skip to content

feat: allow www domain - #3

Merged
ArthurData merged 2 commits into
mainfrom
quick-wins
Aug 13, 2026
Merged

feat: allow www domain#3
ArthurData merged 2 commits into
mainfrom
quick-wins

Conversation

@ArthurData

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates {css2r}’s URL/CSS-link handling so that sites that redirect between apex and www (and serve stylesheets from the redirected host) can still be analyzed, and surfaces discarded (off-site) stylesheets more clearly in the Shiny app.

Changes:

  • Track the final URL reached after redirects (resolved_url) and resolve/filter stylesheet links against it.
  • Filter stylesheets by registrable domain (eTLD+1) and record discarded links (dropped_css_links) for messaging.
  • Add regression tests for www redirects and for reporting dropped external stylesheets; update app modals accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
R/css2r.R Implements redirect-aware HTML download, registrable-domain filtering, and tracking/reporting of dropped stylesheet links.
R/app_server.R Adds a dedicated modal for the “external stylesheets only” case and improves the “no stylesheet found” messaging.
tests/testthat/test-css2r.R Adds regression tests for apex→www redirect handling and for dropping/reporting cross-domain stylesheets.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread R/css2r.R
Comment on lines +173 to +187
absolute_links <- self$all_css_links |>
map_chr(
.f = ~ ifelse(
test = startsWith(.x, "http"),
yes = .x,
no = url_absolute(.x, self$url)
no = url_absolute(.x, base_url)
)
) |>
keep(
.p = ~ domain(.x) == self$domain
)

# Compare registrable domains (eTLD+1), not full hosts: www.example.com and
# example.com are the same site, while cdn.other.com is not.
is_same_site <- purrr::map_lgl(
.x = absolute_links,
.f = ~ identical(private$registrable_domain(.x), site_domain)
)
Comment thread R/css2r.R
Comment on lines +128 to +130
self$html_page <- read_html(
content(response, as = "text", encoding = "UTF-8")
)
Comment on lines +48 to +50
expect_equal(apex$domain, "lemonde.fr")
expect_equal(apex$resolved_url, "https://www.lemonde.fr/")
expect_true(length(apex$domain_css_links) > 0)
@ArthurData
ArthurData merged commit 3ed35b5 into main Aug 13, 2026
5 checks passed
@ArthurData
ArthurData deleted the quick-wins branch August 13, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants