Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-absolute

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-absolute - npm Package Compare versions

Comparing version 0.1.7 to 0.2.0

51

index.js

@@ -1,27 +0,50 @@

/*!
* is-absolute <https://github.com/jonschlinkert/is-absolute>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var isRelative = require('is-relative');
var windows = process.platform === 'win32';
module.exports = function isAbsolute(filepath) {
if ('/' === filepath[0]) {
/**
* Returns true if a file path is absolute.
*
* @param {String} `fp`
* @return {Boolean}
*/
function isAbsolute(fp) {
if (typeof fp !== 'string') {
throw new TypeError('isAbsolute expects a string.');
}
if (!windows && isAbsolute.posix(fp)) {
return true;
}
if (':' === filepath[1] && '\\' === filepath[2]) {
return isAbsolute.win32(fp);
};
/**
* Test posix paths.
*/
isAbsolute.posix = function posixPath(fp) {
return fp.charAt(0) === '/';
};
/**
* Test windows paths.
*/
isAbsolute.win32 = function win32(fp) {
if (/[a-z]/i.test(fp.charAt(0)) && fp.charAt(1) === ':' && fp.charAt(2) === '\\') {
return true;
}
// Microsoft Azure absolute filepath
if ('\\\\' == filepath.substring(0, 2)) {
if (fp.slice(0, 2) === '\\\\') {
return true;
}
if (!isRelative(filepath)) {
return true;
}
return !isRelative(fp);
};
/**
* Expose `isAbsolute`
*/
module.exports = isAbsolute;
{
"name": "is-absolute",
"description": "Return true if a file path is absolute.",
"version": "0.1.7",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/is-absolute",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/is-absolute.git"
},
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/is-absolute",
"bugs": {
"url": "https://github.com/jonschlinkert/is-absolute/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/is-absolute/blob/master/LICENSE"
},
"license": "MIT",
"files": [

@@ -32,3 +23,3 @@ "index.js"

"dependencies": {
"is-relative": "^0.1.0"
"is-relative": "^0.2.0"
},

@@ -46,3 +37,3 @@ "devDependencies": {

"path",
"path.relative",
"path.absolute",
"relative",

@@ -54,3 +45,15 @@ "resolve",

"url"
]
],
"verb": {
"related": {
"list": [
"is-absolute",
"is-relative",
"is-dotfile",
"is-glob",
"is-unc-path",
"is-valid-glob"
]
}
}
}

@@ -1,2 +0,2 @@

# is-absolute [![NPM version](https://badge.fury.io/js/is-absolute.svg)](http://badge.fury.io/js/is-absolute) [![Build Status](https://travis-ci.org/jonschlinkert/is-absolute.svg)](https://travis-ci.org/jonschlinkert/is-absolute)
# is-absolute [![NPM version](https://badge.fury.io/js/is-absolute.svg)](http://badge.fury.io/js/is-absolute) [![Build Status](https://travis-ci.org/jonschlinkert/is-absolute.svg)](https://travis-ci.org/jonschlinkert/is-absolute)

@@ -7,6 +7,8 @@ > Return true if a file path is absolute.

## Install with [npm](npmjs.org)
## Install
```bash
npm i is-absolute --save
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i is-absolute --save
```

@@ -18,38 +20,76 @@

var isAbsolute = require('is-absolute');
console.log(isAbsolute('a/b/c.js'));
//=> 'false';
isAbsolute('a/b/c.js');
//=> 'false'
isAbsolute('/a/b/c.js');
//=> 'true'
```
## Running tests
Install dev dependencies.
**Explicitly test windows paths**
```bash
npm i -d && npm test
```js
isAbsolute.posix('/foo/bar');
isAbsolute.posix('/user/docs/Letter.txt');
//=> true
isAbsolute.posix('foo/bar');
//=> false
```
**Explicitly test windows paths**
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-absolute/issues)
```js
var isAbsolute = require('is-absolute');
isAbsolute.win32('c:\\');
isAbsolute.win32('//C://user\\docs\\Letter.txt');
isAbsolute.win32('\\\\unc\\share');
isAbsolute.win32('\\\\unc\\share\\foo');
isAbsolute.win32('\\\\unc\\share\\foo\\');
isAbsolute.win32('\\\\unc\\share\\foo\\bar');
isAbsolute.win32('\\\\unc\\share\\foo\\bar\\');
isAbsolute.win32('\\\\unc\\share\\foo\\bar\\baz');
//=> true
isAbsolute.win32('a:foo/a/b/c/d');
isAbsolute.win32(':\\');
isAbsolute.win32('foo\\bar\\baz');
isAbsolute.win32('foo\\bar\\baz\\');
//=> false
```
## Other projects
* [is-relative](https://github.com/jonschlinkert/is-relative): Returns `true` if the path appears to be relative.
* [is-dotfile](https://github.com/regexps/is-dotfile): Return true if a file path is (or has) a dotfile.
* [is-dotfile](https://github.com/jonschlinkert/is-dotfile): Return true if a file path is (or has) a dotfile.
* [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern.
* [cwd](https://github.com/jonschlinkert/cwd): Node.js util for easily getting the current working directory of a project based on package.json or the given path.
* [git-config-path](https://github.com/jonschlinkert/git-config-path): Resolve the path to the user's global .gitconfig.
* [is-unc-path](https://github.com/jonschlinkert/is-unc-path): Returns true if a filepath is a windows UNC file path.
* [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob): Return true if a value is a valid glob pattern or patterns.
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-absolute/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license
Copyright © 2014-2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 05, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 07, 2015._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc