Menu

gitpiper

untildify javascript Code Snippet in 2024

nodestringbeginner

Last Updated: 20 April 2024

Converts a tilde path to an absolute path.

  • Use String.prototype.replace() with a regular expression and os.homedir() to replace the ~ in the start of the path with the home directory.
const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`);
untildify('~/node'); // '/Users/aUser/node'

javascript snippet similar to untildify For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️