Extracts the filename from a given file path.
filename('/home/demo/pictures/dummy.jpeg').value// => "dummy.jpeg"filename('/home/demo/profile').value// => "profile"filename('/home/demo/pictures/').value// => ""filename('C:\\Users\\Documents\\File1.txt').value// => 'File1.txt'filename('/var/www/html/index.html').value// => 'index.html''filename('https://example.com/assets/image.png').value// => 'image.png'const fname = filename(12345)fname.isOk()// => falsefname.isErr()// truefname.error.message// => '[paths.filename] Expected string value as input' Copy
filename('/home/demo/pictures/dummy.jpeg').value// => "dummy.jpeg"filename('/home/demo/profile').value// => "profile"filename('/home/demo/pictures/').value// => ""filename('C:\\Users\\Documents\\File1.txt').value// => 'File1.txt'filename('/var/www/html/index.html').value// => 'index.html''filename('https://example.com/assets/image.png').value// => 'image.png'const fname = filename(12345)fname.isOk()// => falsefname.isErr()// truefname.error.message// => '[paths.filename] Expected string value as input'
The file path from which to extract the filename.
A Result object containing the filename as a string on success, or an Error object if the provided input is not a string.
Result
string
Error
Generated using TypeDoc v0.24.7
Extracts the filename from a given file path.
Example