feat: allow www domain - #3
Merged
Merged
Conversation
There was a problem hiding this comment.
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
wwwredirects 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 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 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.