[Pkg-javascript-commits] [node-absolute-path] 01/03: Imported Upstream version 0.0.0

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Sat Mar 21 17:07:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository node-absolute-path.

commit 07586bfb1d0437371b8ef696479ed1705613eccf
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Mar 21 17:46:26 2015 +0100

    Imported Upstream version 0.0.0
---
 .npmignore    | 15 +++++++++++++++
 LICENSE       | 21 +++++++++++++++++++++
 README.md     |  4 ++++
 index.js      | 25 +++++++++++++++++++++++++
 package.json  | 25 +++++++++++++++++++++++++
 test/index.js | 20 ++++++++++++++++++++
 6 files changed, 110 insertions(+)

diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..a72b52e
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+npm-debug.log
+node_modules
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a81f91a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+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.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..012ac27
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+node-absolute-path
+==================
+
+Node.js 0.11.x path.isAbsolute as an installable module
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..ac72e79
--- /dev/null
+++ b/index.js
@@ -0,0 +1,25 @@
+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;
+};
+
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..bff0b57
--- /dev/null
+++ b/package.json
@@ -0,0 +1,25 @@
+{
+  "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"
+}
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..e261e83
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,20 @@
+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);
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-absolute-path.git



More information about the Pkg-javascript-commits mailing list