Skip to content

Commit

Permalink
bring back test with new url parse
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherkenny committed Feb 8, 2025
1 parent b03578d commit 8d5992b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions R/url_uri.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#' @examples
#' bs_uri_to_url('at://did:plc:ic6zqvuw5ulmfpjiwnhsr2ns/app.bsky.feed.post/3k7qmjev5lr2s')
bs_uri_to_url <- function(uri) {
pieces <- httr2::url_parse(uri)
type <- stringr::word(pieces$path, start = 2, sep = stringr::fixed('/'))
pieces <- stringr::str_split(uri, pattern = '/+')[[1]]
paste0(
'https://bsky.app/profile/', pieces$hostname, ':', pieces$port, '/', 'post',
'/', stringr::word(pieces$path, start = 3, sep = stringr::fixed('/'))
'https://bsky.app/profile/', pieces[2], '/', 'post',
'/', pieces[4]
)
}

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-url_uri.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
test_that('uri to url works', {
expect_equal(
bs_uri_to_url('at://did:plc:ic6zqvuw5ulmfpjiwnhsr2ns/app.bsky.feed.post/3k7qmjev5lr2s'),
'https://bsky.app/profile/did:plc:ic6zqvuw5ulmfpjiwnhsr2ns/post/3k7qmjev5lr2s'
)
})

with_mock_dir('t/o/url2uri', {
test_that('urls to uri works post', {
expect_equal(
Expand Down

0 comments on commit 8d5992b

Please sign in to comment.