Last active
May 17, 2024 02:12
-
-
Save microbial/c709072bb9b1a073d879 to your computer and use it in GitHub Desktop.
isAbsolutePath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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