is-relative-path
Advanced tools
Comparing version 1.0.2 to 2.0.0
12
index.js
@@ -1,13 +0,9 @@ | ||
var util = require('util'); | ||
var isAbsolute = require('path').isAbsolute; | ||
/** | ||
* @param {String} filename | ||
* @param {String} path | ||
* @return {Boolean} | ||
*/ | ||
module.exports = function (filename) { | ||
if (typeof filename !== 'string') { | ||
throw new TypeError('Path must be a string. Received ' + util.inspect(filename)); | ||
} | ||
return filename[0] === '.'; | ||
module.exports = function isRelative(path) { | ||
return !isAbsolute(path); | ||
}; |
{ | ||
"name": "is-relative-path", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Whether or not a given path is relative", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=0.11.2" | ||
}, | ||
"directories": { | ||
@@ -27,3 +30,3 @@ "test": "test" | ||
"devDependencies": { | ||
"jscs": "~3.0.3", | ||
"jscs": "^2.0.0", | ||
"mocha": "~2.4.5" | ||
@@ -30,0 +33,0 @@ }, |
@@ -9,2 +9,7 @@ ### is-relative-path [![npm](http://img.shields.io/npm/v/is-relative-path.svg)](https://npmjs.org/package/is-relative-path) [![npm](http://img.shields.io/npm/dm/is-relative-path.svg)](https://npmjs.org/package/is-relative-path) | ||
#### `isRelative(path)` | ||
- `path` `<string>` | ||
- Returns: `<boolean>` | ||
```js | ||
@@ -17,2 +22,20 @@ var isRelative = require('is-relative-path'); | ||
### Breaking change | ||
#### Code | ||
| Version | Code | | ||
| ------- | -----------------------------------| | ||
| 1.x | `(path) => path[0] === '.'` | | ||
| 2.x | `(path) => !path.isAbsolute(path)` | | ||
#### Test | ||
| path | v1.x | v2.x | | ||
| --------- | -------- | -------- | | ||
| `"" ` | false | **true** | | ||
| `"."` | true | true | | ||
| `".."` | true | true | | ||
| `"foo"` | false | **true** | | ||
| `"/foo"` | false | false | | ||
@@ -6,2 +6,4 @@ var assert = require('assert'); | ||
it('returns true if the given path is relative', function () { | ||
assert.ok(isRelative('')); | ||
assert.ok(isRelative('.')); | ||
assert.ok(isRelative('../')); | ||
@@ -14,2 +16,5 @@ assert.ok(isRelative('../foo.js')); | ||
assert.ok(isRelative('../../../../')); | ||
assert.ok(isRelative('foo.js')); | ||
assert.ok(isRelative('foo')); | ||
assert.ok(isRelative('foo/bar/car/baz.js')); | ||
}); | ||
@@ -20,5 +25,2 @@ | ||
assert.ok(!isRelative('/foo.js')); | ||
assert.ok(!isRelative('foo.js')); | ||
assert.ok(!isRelative('foo')); | ||
assert.ok(!isRelative('foo/bar/car/baz.js')); | ||
}); | ||
@@ -25,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3386
40
40