Socket
Socket
Sign inDemoInstall

upath

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

upath - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

26

build/code/upath.js
/*!
* upath - version 0.1.3
* Compiled on 2014-10-30
* Compiled on 2014-11-08
* git://github.com/anodynos/upath

@@ -10,3 +10,3 @@ * Copyright(c) 2014 Agelos Pikoulas (agelos.pikoulas@gmail.com )

// Generated by CoffeeScript 1.8.0
var extraFn, extraFunctions, fName, fn, isValidExt, name, path, upath, _,
var extraFn, extraFunctions, fName, fn, isValidExt, name, path, toUnix, upath, _,
__slice = [].slice,

@@ -23,4 +23,14 @@ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

upath.VERSION = VERSION;
upath.VERSION = typeof VERSION !== "undefined" && VERSION !== null ? VERSION : 'NO-VERSION';
toUnix = function(p) {
var double;
p = p.replace(/\\/g, '/');
double = /\/\//;
while (p.match(double)) {
p = p.replace(double, '/');
}
return p;
};
for (fName in path) {

@@ -34,9 +44,9 @@ fn = path[fName];

args = _.map(args, function(p) {
if (!_.isString(p)) {
if (_.isString(p)) {
return toUnix(p);
} else {
return p;
} else {
return p.replace(/\\/g, '/');
}
});
return path[fName].apply(path, args);
return toUnix(path[fName].apply(path, args));
};

@@ -48,3 +58,5 @@ })(fName);

extraFunctions = {
toUnix: toUnix,
normalizeSafe: function(p) {
p = toUnix(p);
if (_.startsWith(p, './')) {

@@ -51,0 +63,0 @@ if (_.startsWith(p, './..') || (p === './')) {

{
"name": "upath",
"description": "A proxy to `path`, replacing `\\` with `/` for all results & methods to add, change, default, trim file extensions.",
"version": "0.1.3",
"version": "0.1.4",
"homepage": "http://github.com/anodynos/upath/",

@@ -6,0 +6,0 @@ "author": {

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

# upath v0.1.3
# upath v0.1.4

@@ -14,2 +14,4 @@ [![Build Status](https://travis-ci.org/anodynos/upath.svg?branch=master)](https://travis-ci.org/anodynos/upath)

* Plus a helper `toUnix` that simply converts `` to `/` and consolidates duplicates.
**Useful note: these docs are actually auto generated from [specs](https://github.com/anodynos/upath/blob/master/source/spec/upath-spec.coffee), running on Linux.**

@@ -20,3 +22,3 @@

Normal `path` doesn't convert paths to a unified format (ie `/`) before calculating paths (`normalize`, `join`), which can lead to numerous problems.
Also path joining, normalization etc on the two formats is not consistent, depending on where it runs - last checked with nodejs 0.10.32 running on Linux.
Also path joining, normalization etc on the two formats is not consistent, depending on where it runs - last checked with nodejs 0.10.32 running on Linux & Windows x64.
Running on Windows `path` yields different results.

@@ -30,3 +32,2 @@

Check out the different (improved) behavior to vanilla `path`:

@@ -36,11 +37,11 @@

✓ `'c:/windows/nodejs/path'` ---> `'c:/windows/nodejs/path`' // equal to `path.normalize()`
✓ `'c:/windows/../nodejs/path'` ---> `'c:/nodejs/path`' // equal to `path.normalize()`
✓ `'c:\\windows\\nodejs\\path'` ---> `'c:/windows/nodejs/path`' // `path.normalize()` gives `'c:\windows\nodejs\path'`
✓ `'c:\\windows\\..\\nodejs\\path'` ---> `'c:/nodejs/path`' // `path.normalize()` gives `'c:\windows\..\nodejs\path'`
✓ `'//windows\\unix/mixed'` ---> `'/windows/unix/mixed`' // `path.normalize()` gives `'/windows\unix/mixed'`
✓ `'\\windows//unix/mixed'` ---> `'/windows/unix/mixed`' // `path.normalize()` gives `'\windows/unix/mixed'`
✓ `'//windows\\..\\unix/mixed/'` ---> `'/unix/mixed/`' // `path.normalize()` gives `'/windows\..\unix/mixed/'`
✓ `'c:/windows/nodejs/path'` ---> `'c:/windows/nodejs/path'` // equal to `path.normalize()`
✓ `'c:/windows/../nodejs/path'` ---> `'c:/nodejs/path'` // equal to `path.normalize()`
✓ `'c:\\windows\\nodejs\\path'` ---> `'c:/windows/nodejs/path'` // `path.normalize()` gives `'c:\windows\nodejs\path'`
✓ `'c:\\windows\\..\\nodejs\\path'` ---> `'c:/nodejs/path'` // `path.normalize()` gives `'c:\windows\..\nodejs\path'`
✓ `'//windows\\unix/mixed'` ---> `'/windows/unix/mixed'` // `path.normalize()` gives `'/windows\unix/mixed'`
✓ `'\\windows//unix/mixed'` ---> `'/windows/unix/mixed'` // `path.normalize()` gives `'\windows/unix/mixed'`
✓ `'////\\windows\\..\\unix/mixed/'` ---> `'/unix/mixed/'` // `path.normalize()` gives `'/\windows\..\unix/mixed/'`
Joining paths can also be a problem:

@@ -50,10 +51,22 @@

✓ `'some/nodejs/deep', '../path'` ---> `'some/nodejs/path`' // equal to `path.join()`
✓ `'some/nodejs\\windows', '../path'` ---> `'some/nodejs/path`' // `path.join()` gives `'some/path'`
✓ `'some\\windows\\only', '..\\path'` ---> `'some/windows/path`' // `path.join()` gives `'some\windows\only/..\path'`
✓ `'some/nodejs/deep', '../path'` ---> `'some/nodejs/path'` // equal to `path.join()`
✓ `'some/nodejs\\windows', '../path'` ---> `'some/nodejs/path'` // `path.join()` gives `'some/path'`
✓ `'some\\windows\\only', '..\\path'` ---> `'some/windows/path'` // `path.join()` gives `'some\windows\only/..\path'`
## Added functions
#### `upath.toUnix(path)`
Just converts all `` to `/` and consolidates duplicates, without performing any normalization.
##### Examples / specs
`upath.toUnix(path)` --returns-->
✓ `'.//windows\//unix//mixed////'` ---> `'./windows/unix/mixed/'`
✓ `'..///windows\..\\unix/mixed'` ---> `'../windows/../unix/mixed'`
#### `upath.normalizeSafe(path)`

@@ -69,22 +82,27 @@

✓ `''` ---> `'.`' // equal to `path.normalize()`
✓ `'.'` ---> `'.`' // equal to `path.normalize()`
✓ `'./'` ---> `'./`' // equal to `path.normalize()`
✓ `'./..'` ---> `'..`' // equal to `path.normalize()`
✓ `'./../'` ---> `'../`' // equal to `path.normalize()`
✓ `'./../dep'` ---> `'../dep`' // equal to `path.normalize()`
✓ `'../dep'` ---> `'../dep`' // equal to `path.normalize()`
✓ `'../path/dep'` ---> `'../path/dep`' // equal to `path.normalize()`
✓ `'../path/../dep'` ---> `'../dep`' // equal to `path.normalize()`
✓ `'dep'` ---> `'dep`' // equal to `path.normalize()`
✓ `'path//dep'` ---> `'path/dep`' // equal to `path.normalize()`
✓ `'./dep'` ---> `'./dep`' // `path.normalize()` gives `'dep'`
✓ `'./path/dep'` ---> `'./path/dep`' // `path.normalize()` gives `'path/dep'`
✓ `'./path/../dep'` ---> `'./dep`' // `path.normalize()` gives `'dep'`
✓ `'.//windows\\unix/mixed/'` ---> `'./windows/unix/mixed/`' // `path.normalize()` gives `'windows\unix/mixed/'`
✓ `'..//windows\\unix/mixed'` ---> `'../windows/unix/mixed`' // `path.normalize()` gives `'../windows\unix/mixed'`
✓ `'windows\\unix/mixed/'` ---> `'windows/unix/mixed/`' // `path.normalize()` gives `'windows\unix/mixed/'`
✓ `'..//windows\\..\\unix/mixed'` ---> `'../unix/mixed`' // `path.normalize()` gives `'../windows\..\unix/mixed'`
✓ `''` ---> `'.'` // equal to `path.normalize()`
✓ `'.'` ---> `'.'` // equal to `path.normalize()`
✓ `'./'` ---> `'./'` // equal to `path.normalize()`
✓ `'.//'` ---> `'./'` // equal to `path.normalize()`
✓ `'.\\'` ---> `'./'` // `path.normalize()` gives `'.\'`
✓ `'.\\//'` ---> `'./'` // `path.normalize()` gives `'.\/'`
✓ `'./..'` ---> `'..'` // equal to `path.normalize()`
✓ `'.//..'` ---> `'..'` // equal to `path.normalize()`
✓ `'./../'` ---> `'../'` // equal to `path.normalize()`
✓ `'.\\..\\'` ---> `'../'` // `path.normalize()` gives `'.\..\'`
✓ `'./../dep'` ---> `'../dep'` // equal to `path.normalize()`
✓ `'../dep'` ---> `'../dep'` // equal to `path.normalize()`
✓ `'../path/dep'` ---> `'../path/dep'` // equal to `path.normalize()`
✓ `'../path/../dep'` ---> `'../dep'` // equal to `path.normalize()`
✓ `'dep'` ---> `'dep'` // equal to `path.normalize()`
✓ `'path//dep'` ---> `'path/dep'` // equal to `path.normalize()`
✓ `'./dep'` ---> `'./dep'` // `path.normalize()` gives `'dep'`
✓ `'./path/dep'` ---> `'./path/dep'` // `path.normalize()` gives `'path/dep'`
✓ `'./path/../dep'` ---> `'./dep'` // `path.normalize()` gives `'dep'`
✓ `'.//windows\\unix/mixed/'` ---> `'./windows/unix/mixed/'` // `path.normalize()` gives `'windows\unix/mixed/'`
✓ `'..//windows\\unix/mixed'` ---> `'../windows/unix/mixed'` // `path.normalize()` gives `'../windows\unix/mixed'`
✓ `'windows\\unix/mixed/'` ---> `'windows/unix/mixed/'` // `path.normalize()` gives `'windows\unix/mixed/'`
✓ `'..//windows\\..\\unix/mixed'` ---> `'../unix/mixed'` // `path.normalize()` gives `'../windows\..\unix/mixed'`
#### `upath.normalizeTrim(path)`

@@ -98,9 +116,9 @@

✓ `'./'` ---> `'.`' // `upath.normalizeSafe()` gives `'./'`
✓ `'./../'` ---> `'..`' // `upath.normalizeSafe()` gives `'../'`
✓ `'./../dep/'` ---> `'../dep`' // `upath.normalizeSafe()` gives `'../dep/'`
✓ `'path//dep\\'` ---> `'path/dep`' // `upath.normalizeSafe()` gives `'path/dep/'`
✓ `'.//windows\\unix/mixed/'` ---> `'./windows/unix/mixed`' // `upath.normalizeSafe()` gives `'./windows/unix/mixed/'`
✓ `'./'` ---> `'.'` // `upath.normalizeSafe()` gives `'./'`
✓ `'./../'` ---> `'..'` // `upath.normalizeSafe()` gives `'../'`
✓ `'./../dep/'` ---> `'../dep'` // `upath.normalizeSafe()` gives `'../dep/'`
✓ `'path//dep\\'` ---> `'path/dep'` // `upath.normalizeSafe()` gives `'path/dep/'`
✓ `'.//windows\\unix/mixed/'` ---> `'./windows/unix/mixed'` // `upath.normalizeSafe()` gives `'./windows/unix/mixed/'`
## Added functions for *filename extension* manipulation.

@@ -118,4 +136,4 @@

#### `upath.addExt(filename, [ext])`

@@ -129,8 +147,8 @@

✓ `'myfile/addExt'` ---> `'myfile/addExt.js`'
✓ `'myfile/addExt.txt'` ---> `'myfile/addExt.txt.js`'
✓ `'myfile/addExt.js'` ---> `'myfile/addExt.js`'
✓ `'myfile/addExt.min.'` ---> `'myfile/addExt.min..js`'
✓ `'myfile/addExt'` ---> `'myfile/addExt.js'`
✓ `'myfile/addExt.txt'` ---> `'myfile/addExt.txt.js'`
✓ `'myfile/addExt.js'` ---> `'myfile/addExt.js'`
✓ `'myfile/addExt.min.'` ---> `'myfile/addExt.min..js'`
It adds nothing if no `ext` param is passed.

@@ -140,8 +158,8 @@

✓ `'myfile/addExt'` ---> `'myfile/addExt`'
✓ `'myfile/addExt.txt'` ---> `'myfile/addExt.txt`'
✓ `'myfile/addExt.js'` ---> `'myfile/addExt.js`'
✓ `'myfile/addExt.min.'` ---> `'myfile/addExt.min.`'
✓ `'myfile/addExt'` ---> `'myfile/addExt'`
✓ `'myfile/addExt.txt'` ---> `'myfile/addExt.txt'`
✓ `'myfile/addExt.js'` ---> `'myfile/addExt.js'`
✓ `'myfile/addExt.min.'` ---> `'myfile/addExt.min.'`
#### `upath.trimExt(filename, [ignoreExts], [maxSize=7])`

@@ -159,9 +177,9 @@

✓ `'my/trimedExt.txt'` ---> `'my/trimedExt`'
✓ `'my/trimedExt'` ---> `'my/trimedExt`'
✓ `'my/trimedExt.min'` ---> `'my/trimedExt`'
✓ `'my/trimedExt.min.js'` ---> `'my/trimedExt.min`'
✓ `'../my/trimedExt.longExt'` ---> `'../my/trimedExt.longExt`'
✓ `'my/trimedExt.txt'` ---> `'my/trimedExt'`
✓ `'my/trimedExt'` ---> `'my/trimedExt'`
✓ `'my/trimedExt.min'` ---> `'my/trimedExt'`
✓ `'my/trimedExt.min.js'` ---> `'my/trimedExt.min'`
✓ `'../my/trimedExt.longExt'` ---> `'../my/trimedExt.longExt'`
It is ignoring `.min` & `.dev` as extensions, and considers exts with up to 8 chars.

@@ -171,9 +189,9 @@

✓ `'my/trimedExt.txt'` ---> `'my/trimedExt`'
✓ `'my/trimedExt.min'` ---> `'my/trimedExt.min`'
✓ `'my/trimedExt.dev'` ---> `'my/trimedExt.dev`'
✓ `'../my/trimedExt.longExt'` ---> `'../my/trimedExt`'
✓ `'../my/trimedExt.longRExt'` ---> `'../my/trimedExt.longRExt`'
✓ `'my/trimedExt.txt'` ---> `'my/trimedExt'`
✓ `'my/trimedExt.min'` ---> `'my/trimedExt.min'`
✓ `'my/trimedExt.dev'` ---> `'my/trimedExt.dev'`
✓ `'../my/trimedExt.longExt'` ---> `'../my/trimedExt'`
✓ `'../my/trimedExt.longRExt'` ---> `'../my/trimedExt.longRExt'`
#### `upath.changeExt(filename, [ext], [ignoreExts], [maxSize=7])`

@@ -191,9 +209,9 @@

✓ `'my/module.min'` ---> `'my/module.js`'
✓ `'my/module.coffee'` ---> `'my/module.js`'
✓ `'my/module'` ---> `'my/module.js`'
✓ `'file/withDot.'` ---> `'file/withDot.js`'
✓ `'file/change.longExt'` ---> `'file/change.longExt.js`'
✓ `'my/module.min'` ---> `'my/module.js'`
✓ `'my/module.coffee'` ---> `'my/module.js'`
✓ `'my/module'` ---> `'my/module.js'`
✓ `'file/withDot.'` ---> `'file/withDot.js'`
✓ `'file/change.longExt'` ---> `'file/change.longExt.js'`
If no `ext` param is given, it trims the current extension (if any).

@@ -203,9 +221,9 @@

✓ `'my/module.min'` ---> `'my/module`'
✓ `'my/module.coffee'` ---> `'my/module`'
✓ `'my/module'` ---> `'my/module`'
✓ `'file/withDot.'` ---> `'file/withDot`'
✓ `'file/change.longExt'` ---> `'file/change.longExt`'
✓ `'my/module.min'` ---> `'my/module'`
✓ `'my/module.coffee'` ---> `'my/module'`
✓ `'my/module'` ---> `'my/module'`
✓ `'file/withDot.'` ---> `'file/withDot'`
✓ `'file/change.longExt'` ---> `'file/change.longExt'`
It is ignoring `.min` & `.dev` as extensions, and considers exts with up to 8 chars.

@@ -215,9 +233,9 @@

✓ `'my/module.coffee'` ---> `'my/module.js`'
✓ `'file/notValidExt.min'` ---> `'file/notValidExt.min.js`'
✓ `'file/notValidExt.dev'` ---> `'file/notValidExt.dev.js`'
✓ `'file/change.longExt'` ---> `'file/change.js`'
✓ `'file/change.longRExt'` ---> `'file/change.longRExt.js`'
✓ `'my/module.coffee'` ---> `'my/module.js'`
✓ `'file/notValidExt.min'` ---> `'file/notValidExt.min.js'`
✓ `'file/notValidExt.dev'` ---> `'file/notValidExt.dev.js'`
✓ `'file/change.longExt'` ---> `'file/change.js'`
✓ `'file/change.longRExt'` ---> `'file/change.longRExt.js'`
#### `upath.defaultExt(filename, [ext], [ignoreExts], [maxSize=7])`

@@ -235,8 +253,8 @@

✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt.js`'
✓ `'fileWith/defaultExt.js'` ---> `'fileWith/defaultExt.js`'
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min`'
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt.js`'
✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt.js'`
✓ `'fileWith/defaultExt.js'` ---> `'fileWith/defaultExt.js'`
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min'`
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt.js'`
If no `ext` param is passed, it leaves filename intact.

@@ -246,8 +264,8 @@

✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt`'
✓ `'fileWith/defaultExt.js'` ---> `'fileWith/defaultExt.js`'
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min`'
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt`'
✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt'`
✓ `'fileWith/defaultExt.js'` ---> `'fileWith/defaultExt.js'`
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min'`
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt'`
It is ignoring `.min` & `.dev` as extensions, and considers exts with up to 8 chars.

@@ -257,36 +275,9 @@

✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt.js`'
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min.js`'
✓ `'fileWith/defaultExt.dev'` ---> `'fileWith/defaultExt.dev.js`'
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt`'
✓ `'fileWith/defaultExt.longRext'` ---> `'fileWith/defaultExt.longRext.js`'
✓ `'fileWith/defaultExt'` ---> `'fileWith/defaultExt.js'`
✓ `'fileWith/defaultExt.min'` ---> `'fileWith/defaultExt.min.js'`
✓ `'fileWith/defaultExt.dev'` ---> `'fileWith/defaultExt.dev.js'`
✓ `'fileWith/defaultExt.longExt'` ---> `'fileWith/defaultExt.longExt'`
✓ `'fileWith/defaultExt.longRext'` ---> `'fileWith/defaultExt.longRext.js'`
80 passing (31ms)
# License
The MIT License
Copyright (c) 2013-2014 Agelos Pikoulas (agelos.pikoulas@gmail.com)
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.
87 passing (37ms)
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