url_destination: Get the final destination of a URL

View source: R/io.R

url_destinationR Documentation

Get the final destination of a URL

Description

If a URL is redirected, query the new location via curlGetHeaders(), otherwise return the original URL.

Usage

url_destination(x, force = FALSE)

Arguments

x

A character vector of URLs.

force

By default, the query is cached in the current R session. To bypass the cache, use force = TRUE.

Value

The final destination(s). If the URL returns a status code greater than or equal to 400, it will throw an error.

Examples

u = "https://tinytex.yihui.org"  # redirected to https://yihui.org/tinytex/
if (url_accessible(u)) url_destination(u)

xfun documentation built on April 3, 2025, 7:04 p.m.