package/package.json000666 000000 000000 0000001103 12311646170012765 0ustar00000000 000000 { "name": "absolute-path", "version": "0.0.0", "description": "Node.js 0.11.x path.isAbsolute as a separate module", "main": "index.js", "scripts": { "test": "node test/index.js" }, "repository": { "type": "git", "url": "https://github.com/filearts/node-absolute-path" }, "keywords": [ "path", "absolute", "isabsolute", "windows" ], "author": "Geoff Goodman", "license": "MIT", "bugs": { "url": "https://github.com/filearts/node-absolute-path/issues" }, "homepage": "https://github.com/filearts/node-absolute-path" } package/.npmignore000666 000000 000000 0000000141 12311646170012477 0ustar00000000 000000 lib-cov *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results npm-debug.log node_modules package/README.md000666 000000 000000 0000000137 12311646170011764 0ustar00000000 000000 node-absolute-path ================== Node.js 0.11.x path.isAbsolute as an installable module package/LICENSE000666 000000 000000 0000002062 12311646170011511 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2014 filearts Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.package/index.js000666 000000 000000 0000001277 12311646170012160 0ustar00000000 000000 var currentPlatform = process !== void 0 ? process.platform : ''; function isAbsolute (path) { if (currentPlatform === 'win32') { // Regex to split a windows path into three parts: [*, device, slash, // tail] windows-only var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; var result = splitDeviceRe.exec(path), device = result[1] || '', isUnc = device && device.charAt(1) !== ':'; // UNC paths are always absolute return !!result[2] || isUnc; } else { return path.charAt(0) === '/'; } } module.exports = isAbsolute; isAbsolute.setPlatform = function (platform) { currentPlatform = platform; }; package/test/index.js000666 000000 000000 0000001333 12311646170013130 0ustar00000000 000000 var assert = require('assert'); var isAbsolute = require('../'); isAbsolute.setPlatform('win32'); assert.equal(isAbsolute('//server/file'), true); assert.equal(isAbsolute('\\\\server\\file'), true); assert.equal(isAbsolute('C:/Users/'), true); assert.equal(isAbsolute('C:\\Users\\'), true); assert.equal(isAbsolute('C:cwd/another'), false); assert.equal(isAbsolute('C:cwd\\another'), false); assert.equal(isAbsolute('directory/directory'), false); assert.equal(isAbsolute('directory\\directory'), false); isAbsolute.setPlatform(''); assert.equal(isAbsolute('/home/foo'), true); assert.equal(isAbsolute('/home/foo/..'), true); assert.equal(isAbsolute('bar/'), false); assert.equal(isAbsolute('./baz'), false);