Convert an absolute path to a tilde path by replacing the user's home directory with ~
93
Evaluation — 93%
↑ 1.09xAgent success when using this tile
Create a utility that converts file system paths to a more user-friendly format by replacing the home directory prefix with a tilde symbol.
Your task is to implement a function that takes an absolute file path as input and returns a shortened version where the user's home directory is replaced with ~.
The function should handle the following scenarios:
~~~ @test~ @test@generates
/**
* Converts an absolute path to a tilde path by replacing the home directory.
*
* @param {string} absolutePath - An absolute file system path
* @returns {string} The path with home directory replaced by ~ if applicable
*/
function tildifyPath(absolutePath) {
// Implementation here
}
module.exports = tildifyPath;Provides functionality to convert absolute paths to tilde paths.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-tildify