Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
* `ansi_collapse(style = "head")` no longer exceeds `width` when not even
the first element fits (#570, @taekop).

* `{.url}` with a substituted value, e.g. `{.url https://example.com/{x}}`,
no longer puts ANSI escape sequences into the hyperlink target (#757,
@taekop).

* `cli_progress_update(set = )` no longer fails with a deferred `on.exit()`
error when the progress bar is drawn with a value below zero or above
the total (#580, @taekop).
Expand Down
2 changes: 1 addition & 1 deletion R/ansi-hyperlink.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ make_link_url <- function(txt) {
if (all(linked)) {
return(txt)
}
txt[!linked] <- style_hyperlink(txt[!linked], txt[!linked])
txt[!linked] <- style_hyperlink(txt[!linked], ansi_strip(txt[!linked]))
txt
}

Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-links.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ test_that("make_link_url", {
expect_equal(make_link_url(x), x)
})

test_that("{.url} with a substitution has no ANSI in the link target", {
withr::local_options(
cli.hyperlink = TRUE,
cli.ansi = TRUE,
cli.num_colors = 256
)
test <- "path"
out <- format_inline("{.url https://example.com/{test}}")
target <- sub("^.*?\033\\]8;;([^\a]*)\a.*$", "\\1", out, perl = TRUE)
expect_equal(target, "https://example.com/path")
})

# -- {.vignette} ----------------------------------------------------------

test_that_cli(configs = "plain", links = c("all", "none"), "{.vignette}", {
Expand Down
Loading