Skip to content

Instantly share code, notes, and snippets.

@microbial
Last active May 17, 2024 02:12
Show Gist options
  • Save microbial/c709072bb9b1a073d879 to your computer and use it in GitHub Desktop.
Save microbial/c709072bb9b1a073d879 to your computer and use it in GitHub Desktop.
isAbsolutePath
//Refactor of absolute path check from Express
module.exports = function (path){
var pathIsAbsolute = false,
firstCharIsSlash = path[0] === '/',
containsWinChars = path[1] === ':' && path[2] === '\\';
if(firstCharIsSlash || containsWinChars) {
pathIsAbsolute = true;
}
return pathIsAbsolute;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment