Get the base names of URLs via basename()
, and remove the
possible query parameters or hash from the names.
url_filename(x, default = "index.html")
A character vector of filenames at the end of URLs.
xfun::url_filename("https://yihui.org/images/logo.png")
#> [1] "logo.png"
xfun::url_filename("https://yihui.org/index.html")
#> [1] "index.html"
xfun::url_filename("https://yihui.org/index.html?foo=bar")
#> [1] "index.html"
xfun::url_filename("https://yihui.org/index.html#about")
#> [1] "index.html"
xfun::url_filename("https://yihui.org")
#> [1] "index.html"
xfun::url_filename("https://yihui.org/")
#> [1] "index.html"