From 79bbe8fae7719bc9b8d1e3653c5f5960607042a6 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Thu, 9 Jan 2025 18:01:07 -0800 Subject: [PATCH] Stick with the status quo It appears this is what cli has always done with a leading `./`, so just keep doing that until there's reason not to. --- R/ansi-hyperlink.R | 2 +- tests/testthat/test-ansi-hyperlink.R | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/R/ansi-hyperlink.R b/R/ansi-hyperlink.R index 3f9c59f3..a97500ab 100644 --- a/R/ansi-hyperlink.R +++ b/R/ansi-hyperlink.R @@ -101,7 +101,7 @@ construct_file_link <- function(params) { params$path <- sub("^file://", "", params$path) params$path <- path.expand(params$path) - + looks_absolute <- function(path) { grepl("^/", params$path) || (is_windows() && grepl("^[a-zA-Z]:", params$path)) } diff --git a/tests/testthat/test-ansi-hyperlink.R b/tests/testthat/test-ansi-hyperlink.R index 0a5d1308..a9e68812 100644 --- a/tests/testthat/test-ansi-hyperlink.R +++ b/tests/testthat/test-ansi-hyperlink.R @@ -564,13 +564,18 @@ test_that("construct_file_link() works with custom format and a relative path", "positron://file/working/directory/relative/path:12:5" ) - # FAILING, what do I want to do here? - # expect_equal( - # sanitize_wd2(construct_file_link(list(path = "./relative/path"))), - # "positron://file/working/directory/relative/path" - # ) - # line - # line and column + expect_equal( + sanitize_dir(construct_file_link(list(path = "./relative/path")), what = "wd"), + "positron://file/working/directory/./relative/path" + ) + expect_equal( + sanitize_dir(construct_file_link(list(path = "./relative/path:12")), what = "wd"), + "positron://file/working/directory/./relative/path:12" + ) + expect_equal( + sanitize_dir(construct_file_link(list(path = "./relative/path:12:5")), what = "wd"), + "positron://file/working/directory/./relative/path:12:5" + ) expect_equal( sanitize_dir(construct_file_link(list(path = "~/relative/path")), what = "home"),