pax_global_header 0000666 0000000 0000000 00000000064 13266126663 0014525 g ustar 00root root 0000000 0000000 52 comment=ea100bbecf851e2cc89e54e295e91af7b835fe63
normalize-path-3.0.0/ 0000775 0000000 0000000 00000000000 13266126663 0014457 5 ustar 00root root 0000000 0000000 normalize-path-3.0.0/.editorconfig 0000664 0000000 0000000 00000000441 13266126663 0017133 0 ustar 00root root 0000000 0000000 # http://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false
normalize-path-3.0.0/.eslintrc.json 0000664 0000000 0000000 00000007325 13266126663 0017262 0 ustar 00root root 0000000 0000000 {
"extends": [
"eslint:recommended"
],
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions":{
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},
"globals": {
"document": false,
"navigator": false,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 0,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 0,
"no-with": 2,
"one-var": [0, { "initialized": "never" }],
"operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [0, "never"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yoda": [2, "never"]
}
}
normalize-path-3.0.0/.gitattributes 0000664 0000000 0000000 00000000355 13266126663 0017355 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
*.* text eol=lf
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.less text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary normalize-path-3.0.0/.gitignore 0000664 0000000 0000000 00000000456 13266126663 0016454 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
.idea
.vscode
*.sublime-*
# test related, or directories generated by tests
test/actual
actual
coverage
.nyc*
# npm
node_modules
npm-debug.log
# yarn
yarn.lock
yarn-error.log
# misc
_gh_pages
_draft
_drafts
bower_components
vendor
temp
tmp
TODO.md
package-lock.json normalize-path-3.0.0/.npmrc 0000664 0000000 0000000 00000000022 13266126663 0015571 0 ustar 00root root 0000000 0000000 package-lock=false normalize-path-3.0.0/.travis.yml 0000664 0000000 0000000 00000000214 13266126663 0016565 0 ustar 00root root 0000000 0000000 sudo: false
os:
- linux
- osx
language: node_js
node_js:
- node
- '9'
- '8'
- '7'
- '6'
- '5'
- '4'
- '0.12'
- '0.10'
normalize-path-3.0.0/.verb.md 0000664 0000000 0000000 00000002372 13266126663 0016021 0 ustar 00root root 0000000 0000000 ## Usage
```js
const normalize = require('{%= name %}');
console.log(normalize('\\foo\\bar\\baz\\'));
//=> '/foo/bar/baz'
```
**win32 namespaces**
```js
console.log(normalize('\\\\?\\UNC\\Server01\\user\\docs\\Letter.txt'));
//=> '//?/UNC/Server01/user/docs/Letter.txt'
console.log(normalize('\\\\.\\CdRomX'));
//=> '//./CdRomX'
```
**Consecutive slashes**
Condenses multiple consecutive forward slashes (except for leading slashes in win32 namespaces) to a single slash.
```js
console.log(normalize('.//foo//bar///////baz/'));
//=> './foo/bar/baz'
```
### Trailing slashes
By default trailing slashes are removed. Pass `false` as the last argument to disable this behavior and _**keep** trailing slashes_:
```js
console.log(normalize('foo\\bar\\baz\\', false)); //=> 'foo/bar/baz/'
console.log(normalize('./foo/bar/baz/', false)); //=> './foo/bar/baz/'
```
## Release history
### v3.0
No breaking changes in this release.
- a check was added to ensure that [win32 namespaces][ns] are handled properly by win32 `path.parse()` after a path has been normalized by this library.
- a minor optimization was made to simplify how the trailing separator was handled
[ns]: https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces normalize-path-3.0.0/LICENSE 0000664 0000000 0000000 00000002100 13266126663 0015455 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014-2018, Jon Schlinkert.
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.
normalize-path-3.0.0/README.md 0000664 0000000 0000000 00000012501 13266126663 0015735 0 ustar 00root root 0000000 0000000 # normalize-path [](https://www.npmjs.com/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://npmjs.org/package/normalize-path) [](https://travis-ci.org/jonschlinkert/normalize-path)
> Normalize slashes in a file path to be posix/unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes, unless disabled.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save normalize-path
```
## Usage
```js
const normalize = require('normalize-path');
console.log(normalize('\\foo\\bar\\baz\\'));
//=> '/foo/bar/baz'
```
**win32 namespaces**
```js
console.log(normalize('\\\\?\\UNC\\Server01\\user\\docs\\Letter.txt'));
//=> '//?/UNC/Server01/user/docs/Letter.txt'
console.log(normalize('\\\\.\\CdRomX'));
//=> '//./CdRomX'
```
**Consecutive slashes**
Condenses multiple consecutive forward slashes (except for leading slashes in win32 namespaces) to a single slash.
```js
console.log(normalize('.//foo//bar///////baz/'));
//=> './foo/bar/baz'
```
### Trailing slashes
By default trailing slashes are removed. Pass `false` as the last argument to disable this behavior and _**keep** trailing slashes_:
```js
console.log(normalize('foo\\bar\\baz\\', false)); //=> 'foo/bar/baz/'
console.log(normalize('./foo/bar/baz/', false)); //=> './foo/bar/baz/'
```
## Release history
### v3.0
No breaking changes in this release.
* a check was added to ensure that [win32 namespaces](https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces) are handled properly by win32 `path.parse()` after a path has been normalized by this library.
* a minor optimization was made to simplify how the trailing separator was handled
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Related projects
Other useful path-related libraries:
* [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path "Return true if a file path contains the given path.")
* [is-absolute](https://www.npmjs.com/package/is-absolute): Returns true if a file path is absolute. Does not rely on the path module… [more](https://github.com/jonschlinkert/is-absolute) | [homepage](https://github.com/jonschlinkert/is-absolute "Returns true if a file path is absolute. Does not rely on the path module and can be used as a polyfill for node.js native `path.isAbolute`.")
* [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative "Returns `true` if the path appears to be relative.")
* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Pollyfill for node.js `path.parse`, parses a filepath into an object. | [homepage](https://github.com/jonschlinkert/parse-filepath "Pollyfill for node.js `path.parse`, parses a filepath into an object.")
* [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with "Return `true` if a file path ends with the given string/suffix.")
* [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify "Convert Windows file paths to unix paths.")
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 35 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [phated](https://github.com/phated) |
### Author
**Jon Schlinkert**
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 19, 2018._ normalize-path-3.0.0/benchmark/ 0000775 0000000 0000000 00000000000 13266126663 0016411 5 ustar 00root root 0000000 0000000 normalize-path-3.0.0/benchmark/code/ 0000775 0000000 0000000 00000000000 13266126663 0017323 5 ustar 00root root 0000000 0000000 normalize-path-3.0.0/benchmark/code/current.js 0000664 0000000 0000000 00000000042 13266126663 0021337 0 ustar 00root root 0000000 0000000 module.exports = require('../..'); normalize-path-3.0.0/benchmark/code/no-regex.js 0000664 0000000 0000000 00000001214 13266126663 0021403 0 ustar 00root root 0000000 0000000 module.exports = function normalize(str) {
str = replace(str, '\\', '/');
str = replace(str, '//', '/');
var last = str[str.length - 1];
if (str[0] === '.' && str[1] === '/') {
str = str.substr(2, str.length - 1);
}
if (last === '/') {
str = str.substr(0, str.length - 1);
}
return str.toLowerCase();
};
function replace(str, pattern, replacement) {
var i, from = 0;
while (str.indexOf(pattern, from) !== -1) {
i = str.indexOf(pattern, from);
from = i + pattern.length;
str = str.substr(0, i)
+ replacement
+ str.substr(from, str.length);
from = i + replacement.length;
}
return str;
} normalize-path-3.0.0/benchmark/code/node-path.js 0000664 0000000 0000000 00000000344 13266126663 0021541 0 ustar 00root root 0000000 0000000 var path = require('path');
path.sep = '/';
module.exports = function(fp, stripTrailing) {
fp = path.normalize(fp).replace(/\\+/g, '/');
if (stripTrailing === false) {
return fp;
}
return fp.replace(/\/$/g, '');
};
normalize-path-3.0.0/benchmark/code/regex.js 0000664 0000000 0000000 00000000314 13266126663 0020771 0 ustar 00root root 0000000 0000000 module.exports = function(fp, stripTrailing) {
fp = fp.replace(/[\\\/]+/g, '/');
fp = fp.replace(/^\.\//g, '');
if (stripTrailing === false) {
return fp;
}
return fp.replace(/\/$/g, '');
};
normalize-path-3.0.0/benchmark/code/slice-trailing.js 0000664 0000000 0000000 00000000364 13266126663 0022572 0 ustar 00root root 0000000 0000000 module.exports = function(fp, stripTrailing) {
fp = fp.replace(/[\\\/]+/g, '/');
fp = fp.replace(/^\.\//g, '');
if (stripTrailing === false) {
return fp;
}
return fp.slice(-1) === '/'
? fp.slice(0, fp.length -1)
: fp;
};
normalize-path-3.0.0/benchmark/code/split.js 0000664 0000000 0000000 00000000262 13266126663 0021014 0 ustar 00root root 0000000 0000000 module.exports = function normalize(str) {
str = str.split('\\').join('//');
if (str[str.length - 1] === '/') {
return str.slice(0, str.length - 1);
}
return str;
};
normalize-path-3.0.0/benchmark/code/v2.js 0000664 0000000 0000000 00000000771 13266126663 0020215 0 ustar 00root root 0000000 0000000 /*!
* normalize-path
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/
var removeTrailingSeparator = require('remove-trailing-separator');
module.exports = function normalizePath(str, stripTrailing) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
str = str.replace(/[\\\/]+/g, '/');
if (stripTrailing !== false) {
str = removeTrailingSeparator(str);
}
return str;
};
normalize-path-3.0.0/benchmark/code/while.js 0000664 0000000 0000000 00000001170 13266126663 0020770 0 ustar 00root root 0000000 0000000 module.exports = function normalize(str, strip) {
var len = str.length, i = -1;
var res = '';
var prev;
while (++i < len) {
var ch = str[i];
if (i === 0) {
if (ch === '.' && str[i + 1] === '/') {
i++;
continue;
}
}
var is = isSlash(ch);
if (i === len - 1 && is) {
if (strip !== false) {
if (prev) res = res.slice(0, res.length -1);
continue;
}
}
if (is) {
if (prev) continue;
res += '/';
} else {
res += ch;
}
prev = is;
}
return res;
};
function isSlash(ch) {
return ch === '\\' || ch === '/';
} normalize-path-3.0.0/benchmark/fixtures/ 0000775 0000000 0000000 00000000000 13266126663 0020262 5 ustar 00root root 0000000 0000000 normalize-path-3.0.0/benchmark/fixtures/long.js 0000664 0000000 0000000 00000001074 13266126663 0021561 0 ustar 00root root 0000000 0000000 'use strict';
/**
* /user/docs/letter.txt'
*/
module.exports = ['\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\\\user\\docs\\Letter.txt']; normalize-path-3.0.0/benchmark/fixtures/short.js 0000664 0000000 0000000 00000000142 13266126663 0021754 0 ustar 00root root 0000000 0000000 'use strict';
/**
* /user/docs/letter.txt'
*/
module.exports = ['c:\\user\\docs\\Letter.txt']; normalize-path-3.0.0/benchmark/fixtures/single.js 0000664 0000000 0000000 00000000030 13266126663 0022072 0 ustar 00root root 0000000 0000000 module.exports = ['\\']; normalize-path-3.0.0/benchmark/fixtures/trailing.js 0000664 0000000 0000000 00000000134 13266126663 0022427 0 ustar 00root root 0000000 0000000 'use strict';
/**
* /user/docs/letter.txt'
*/
module.exports = ['a/b/c/d/e/f/g/', true]; normalize-path-3.0.0/benchmark/fixtures/unix.js 0000664 0000000 0000000 00000000133 13266126663 0021600 0 ustar 00root root 0000000 0000000 module.exports = ['/Users/jonschlinkert/dev/path-utils/normalize-path/benchmark/index.js']; normalize-path-3.0.0/benchmark/fixtures/win.js 0000664 0000000 0000000 00000000144 13266126663 0021414 0 ustar 00root root 0000000 0000000 module.exports = ['C:\\Users\\jonschlinkert\\dev\\path-utils\\normalize-path\\benchmark\\index.js']; normalize-path-3.0.0/benchmark/fixtures/win32-namespace.js 0000664 0000000 0000000 00000000052 13266126663 0023511 0 ustar 00root root 0000000 0000000 module.exports = ['\\\\.\\PhysicalDiskX']; normalize-path-3.0.0/benchmark/index.js 0000664 0000000 0000000 00000000500 13266126663 0020051 0 ustar 00root root 0000000 0000000 'use strict';
const path = require('path');
const suite = require('benchmarked');
const argv = process.argv.slice(2);
const code = argv[0] || '{current,v2}';
suite.run({ code: `code/${code}.js`, fixtures: 'fixtures/*.js' })
.then(function(stats) {
console.log(suite.render(stats));
})
.catch(console.error);
normalize-path-3.0.0/benchmark/package.json 0000664 0000000 0000000 00000000251 13266126663 0020675 0 ustar 00root root 0000000 0000000 {
"name": "benchmarks",
"private": true,
"dependencies": {
"benchmarked": "^2.0.0"
},
"devDependencies": {
"remove-trailing-separator": "^1.1.0"
}
}
normalize-path-3.0.0/bower.json 0000664 0000000 0000000 00000002526 13266126663 0016475 0 ustar 00root root 0000000 0000000 {
"name": "normalize-path",
"description": "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.",
"repository": "jonschlinkert/normalize-path",
"license": "MIT",
"homepage": "https://github.com/jonschlinkert/normalize-path",
"authors": [
"Jon Schlinkert (https://github.com/jonschlinkert)"
],
"main": [
"index.js"
],
"devDependencies": {
"benchmarked": "^2.0.0",
"gulp-format-md": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.5.3"
},
"keywords": [
"absolute",
"backslash",
"delimiter",
"file",
"file-path",
"filepath",
"fix",
"forward",
"fp",
"fs",
"normalize",
"path",
"relative",
"separator",
"slash",
"slashes",
"trailing",
"unix",
"urix"
],
"version": "2.1.1",
"bugs": {
"url": "https://github.com/jonschlinkert/normalize-path/issues"
},
"files": [
"index.js"
],
"dependencies": {
"remove-trailing-separator": "^1.0.1"
},
"ignore": [
"actual",
"bower_components",
"fixtures",
"node_modules",
"temp",
"test",
"test.js",
"tmp"
],
"contributors": [
"Blaine Bublitz (https://twitter.com/BlaineBublitz)",
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
]
} normalize-path-3.0.0/example.js 0000664 0000000 0000000 00000000146 13266126663 0016451 0 ustar 00root root 0000000 0000000
const path = require('path');
console.log(path.win32.parse('//?/UNC/Server01/user/docs/Letter.txt'))
normalize-path-3.0.0/index.js 0000664 0000000 0000000 00000002000 13266126663 0016114 0 ustar 00root root 0000000 0000000 /*!
* normalize-path
*
* Copyright (c) 2014-2018, Jon Schlinkert.
* Released under the MIT License.
*/
module.exports = function(path, stripTrailing) {
if (typeof path !== 'string') {
throw new TypeError('expected path to be a string');
}
if (path === '\\' || path === '/') return '/';
var len = path.length;
if (len <= 1) return path;
// ensure that win32 namespaces has two leading slashes, so that the path is
// handled properly by the win32 version of path.parse() after being normalized
// https://msdn.microsoft.com/library/windows/desktop/aa365247(v=vs.85).aspx#namespaces
var prefix = '';
if (len > 4 && path[3] === '\\') {
var ch = path[2];
if ((ch === '?' || ch === '.') && path.slice(0, 2) === '\\\\') {
path = path.slice(2);
prefix = '//';
}
}
var segs = path.split(/[/\\]+/);
if (stripTrailing !== false && segs[segs.length - 1] === '') {
segs.pop();
}
return prefix + segs.join('/');
};
normalize-path-3.0.0/package.json 0000664 0000000 0000000 00000003202 13266126663 0016742 0 ustar 00root root 0000000 0000000 {
"name": "normalize-path",
"description": "Normalize slashes in a file path to be posix/unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes, unless disabled.",
"version": "3.0.0",
"homepage": "https://github.com/jonschlinkert/normalize-path",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Blaine Bublitz (https://twitter.com/BlaineBublitz)",
"Jon Schlinkert (http://twitter.com/jonschlinkert)"
],
"repository": "jonschlinkert/normalize-path",
"bugs": {
"url": "https://github.com/jonschlinkert/normalize-path/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"devDependencies": {
"gulp-format-md": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.5.3"
},
"keywords": [
"absolute",
"backslash",
"delimiter",
"file",
"file-path",
"filepath",
"fix",
"forward",
"fp",
"fs",
"normalize",
"path",
"relative",
"separator",
"slash",
"slashes",
"trailing",
"unix",
"urix"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"related": {
"description": "Other useful path-related libraries:",
"list": [
"contains-path",
"is-absolute",
"is-relative",
"parse-filepath",
"path-ends-with",
"path-ends-with",
"unixify"
]
},
"lint": {
"reflinks": true
}
}
}
normalize-path-3.0.0/test.js 0000664 0000000 0000000 00000005751 13266126663 0016004 0 ustar 00root root 0000000 0000000 'use strict';
/*!
* normalize-path
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Licensed under the MIT License
*/
require('mocha');
var path = require('path');
var argv = require('minimist')(process.argv.slice(2));
var assert = require('assert');
var normalize = require('./');
if (argv.bench) {
var b = path.join(__dirname, 'benchmark/code', argv.bench);
console.log(b);
normalize = require(b);
}
describe('normalize-path', function() {
describe('single slash', function() {
it('should always return a single forward slash', function() {
assert.equal(normalize('/'), '/');
assert.equal(normalize('/', true), '/');
assert.equal(normalize('\\'), '/');
assert.equal(normalize('\\', true), '/');
});
});
describe('strip trailing slashes', function() {
var units = [
['../../foo/bar', '../../foo/bar'],
['..\\..\\foo/bar', '../../foo/bar'],
['..\\\\..\\\\foo/bar', '../../foo/bar'],
['//foo/bar\\baz', '/foo/bar/baz'],
['//foo\\bar\\baz', '/foo/bar/baz'],
['/user/docs/Letter.txt', '/user/docs/Letter.txt'],
['\\?\\C:\\user\\docs\\Letter.txt', '/?/C:/user/docs/Letter.txt'],
['\\?\\UNC\\Server01\\user\\docs\\Letter.txt', '/?/UNC/Server01/user/docs/Letter.txt'],
['\\\\.\\CdRomX', '//./CdRomX'],
['\\\\.\\PhysicalDiskX', '//./PhysicalDiskX'],
['\\\\?\\C:\\user\\docs\\Letter.txt', '//?/C:/user/docs/Letter.txt'],
['\\\\?\\UNC\\Server01\\user\\docs\\Letter.txt', '//?/UNC/Server01/user/docs/Letter.txt'],
['\\Server01\\user\\docs\\Letter.txt', '/Server01/user/docs/Letter.txt'],
['C:\\user\\docs\\Letter.txt', 'C:/user/docs/Letter.txt'],
['C:\\user\\docs\\somefile.ext:alternate_stream_name', 'C:/user/docs/somefile.ext:alternate_stream_name'],
['C:Letter.txt', 'C:Letter.txt'],
['E://foo//bar//baz', 'E:/foo/bar/baz'],
['E://foo//bar//baz//', 'E:/foo/bar/baz'],
['E://foo//bar//baz//////', 'E:/foo/bar/baz'],
['E://foo/bar\\baz', 'E:/foo/bar/baz'],
['E://foo\\bar\\baz', 'E:/foo/bar/baz'],
['E:/foo/bar/baz/', 'E:/foo/bar/baz'],
['E:/foo/bar/baz///', 'E:/foo/bar/baz'],
['E:\\\\foo/bar\\baz', 'E:/foo/bar/baz'],
['foo\\bar\\baz', 'foo/bar/baz'],
['foo\\bar\\baz\\', 'foo/bar/baz'],
['foo\\bar\\baz\\\\\\', 'foo/bar/baz'],
];
units.forEach(function(unit) {
it('should normalize ' + unit[0], function() {
assert.equal(normalize(unit[0]), unit[1]);
});
});
});
describe('keep trailing slashes', function() {
var units = [
['\\', '/'],
['foo\\bar\\baz\\', 'foo/bar/baz/'],
['foo\\\\bar\\\\baz\\\\', 'foo/bar/baz/'],
['foo//bar//baz//', 'foo/bar/baz/'],
['foo/bar/baz/', 'foo/bar/baz/'],
['./foo/bar/baz/', './foo/bar/baz/']
];
units.forEach(function(unit) {
it('should normalize ' + unit[0], function() {
assert.equal(normalize(unit[0], false), unit[1]);
});
});
});
});