path_sanitize {fs}R Documentation

Sanitize a filename by removing directory paths and invalid characters

Description

path_sanitize() removes the following:

Usage

path_sanitize(filename, replacement = "")

Arguments

filename

A character vector to be sanitized.

replacement

A character vector used to replace invalid characters.

See Also

https://www.npmjs.com/package/sanitize-filename, upon which this function is based.

Examples

# potentially unsafe string
str <- "~/.\u0001ssh/authorized_keys"
path_sanitize(str)

path_sanitize("..")

[Package fs version 1.6.4 Index]