Permalink
Browse files

Get absolute paths properly for windows

  • Loading branch information...
1 parent a7552f6 commit 0a5b548260f6aade177092c967bf490d65ffd47f @isaacs isaacs committed Dec 15, 2011
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/utils/relativize.js
View
@@ -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) {

0 comments on commit 0a5b548

Please sign in to comment.