Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Get absolute paths properly for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Dec 15, 2011
1 parent a7552f6 commit 0a5b548
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/utils/relativize.js
Expand Up @@ -30,7 +30,18 @@ var split = process.platform === "win32" ? /[\/\\]/ : "/"

function isAbsolute (p) {
if (process.platform !== "win32") return p.charAt(0) === "/"
return path.resolve(p) === p


// yanked from node/lib/path.js
var splitDeviceRe =
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/

var result = p.match(splitDeviceRe)
, device = result[1] || ""
, isUnc = device && device.charAt(1) !== ":"
, isAbs = !!result[2] || isUnc // UNC always absolute

return isAbs
}

if (module === require.main) {
Expand Down

0 comments on commit 0a5b548

Please sign in to comment.