pax_global_header00006660000000000000000000000064126226171310014513gustar00rootroot0000000000000052 comment=3ad522d516a41c4f4212c8a4bd5c8005ef62b382 normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/000077500000000000000000000000001262261713100213405ustar00rootroot00000000000000normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.editorconfig000066400000000000000000000006121262261713100240140ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space end_of_line = lf charset = utf-8 indent_size = 2 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false insert_final_newline = false [test/**] trim_trailing_whitespace = false insert_final_newline = false [templates/**] trim_trailing_whitespace = false insert_final_newline = false normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.eslintrc000066400000000000000000000072501262261713100231700ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": 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 }], "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-empty-label": 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": 2, "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-after-keywords": [2, "always"], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, "never"], "space-before-keywords": [2, "always"], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-return-throw-case": 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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.gitattributes000066400000000000000000000003551262261713100242360ustar00rootroot00000000000000# 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 binarynormalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.gitignore000066400000000000000000000010351262261713100233270ustar00rootroot00000000000000# Numerous always-ignore extensions *.csv *.dat *.diff *.err *.gz *.log *.orig *.out *.pid *.rej *.seed *.swo *.swp *.vi *.yo-rc.json *.zip *~ .ruby-version lib-cov # OS or Editor folders *.esproj *.sublime-project *.sublime-workspace ._* .cache .DS_Store .idea .project .settings .tmproj nbproject Thumbs.db # Komodo *.komodoproject .komodotools # grunt-html-validation validation-status.json validation-report.json # Vendor packages node_modules bower_components vendor # General folders and files to ignore _gh_pages tmp temp TODO.mdnormalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.travis.yml000066400000000000000000000002161262261713100234500ustar00rootroot00000000000000sudo: false language: node_js node_js: - "stable" - "0.12" - "0.10" matrix: fast_finish: true allow_failures: - node_js: "0.10" normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/.verb.md000066400000000000000000000014151262261713100226770ustar00rootroot00000000000000# {%= name %} {%= badge("fury") %} {%= badge("travis") %} > {%= description %} ## Install {%= include("install-npm", {save: true}) %} ## Usage ```js var normalize = require('{%= name %}'); normalize('\\foo\\bar\\baz\\'); //=> '/foo/bar/baz' normalize('./foo/bar/baz/'); //=> './foo/bar/baz' ``` Pass `false` as the last argument to **not** strip trailing slashes: ```js normalize('./foo/bar/baz/', false); //=> './foo/bar/baz/' normalize('foo\\bar\\baz\\', false); //=> 'foo/bar/baz/' ``` ## Related {%= verb.related.description %} {%= related(verb.related.list) %} ## Running tests {%= include("tests") %} ## Contributing {%= include("contributing") %} ## Author {%= include("author") %} ## License {%= copyright() %} {%= license() %} *** {%= include("footer") %} normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/LICENSE000066400000000000000000000021001262261713100223360ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-2015, 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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/README.md000066400000000000000000000064371262261713100226310ustar00rootroot00000000000000# normalize-path [![NPM version](https://badge.fury.io/js/normalize-path.svg)](http://badge.fury.io/js/normalize-path) [![Build Status](https://travis-ci.org/jonschlinkert/normalize-path.svg)](https://travis-ci.org/jonschlinkert/normalize-path) > Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes. ## Install Install with [npm](https://www.npmjs.com/) ```sh $ npm i normalize-path --save ``` ## Usage ```js var normalize = require('normalize-path'); normalize('\\foo\\bar\\baz\\'); //=> '/foo/bar/baz' normalize('./foo/bar/baz/'); //=> './foo/bar/baz' ``` Pass `false` as the last argument to **not** strip trailing slashes: ```js normalize('./foo/bar/baz/', false); //=> './foo/bar/baz/' normalize('foo\\bar\\baz\\', false); //=> 'foo/bar/baz/' ``` ## Related Other useful libraries for working with paths in node.js: * [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) * [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://www.npmjs.com/package/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with) * [is-absolute](https://www.npmjs.com/package/is-absolute): Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute) * [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) * [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath) * [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) * [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments) * [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g … [more](https://www.npmjs.com/package/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext) * [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify) ## 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/normalize-path/issues/new). ## Author **Jon Schlinkert** + [github/jonschlinkert](https://github.com/jonschlinkert) + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright © 2015 Jon Schlinkert Released under the MIT license. *** _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 17, 2015._normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/000077500000000000000000000000001262261713100232725ustar00rootroot00000000000000normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/000077500000000000000000000000001262261713100242045ustar00rootroot00000000000000normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/current.js000066400000000000000000000000421262261713100262200ustar00rootroot00000000000000module.exports = require('../..');normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/no-regex.js000066400000000000000000000012141262261713100262640ustar00rootroot00000000000000module.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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/node-path.js000066400000000000000000000003431262261713100264210ustar00rootroot00000000000000var 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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/regex.js000066400000000000000000000003141262261713100256520ustar00rootroot00000000000000module.exports = function(fp, stripTrailing) { fp = fp.replace(/[\\\/]+/g, '/'); fp = fp.replace(/^\.\//g, ''); if (stripTrailing === false) { return fp; } return fp.replace(/\/$/g, ''); }; normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/slice-trailing.js000066400000000000000000000003641262261713100274530ustar00rootroot00000000000000module.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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/split.js000066400000000000000000000002621262261713100256750ustar00rootroot00000000000000module.exports = function normalize(str) { str = str.split('\\').join('//'); if (str[str.length - 1] === '/') { return str.slice(0, str.length - 1); } return str; }; normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/code/while.js000066400000000000000000000011701262261713100256510ustar00rootroot00000000000000module.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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/000077500000000000000000000000001262261713100251435ustar00rootroot00000000000000normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/long.js000066400000000000000000000010741262261713100264420ustar00rootroot00000000000000'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-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-0.js000066400000000000000000000001231262261713100265660ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E://foo//bar//baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-1.js000066400000000000000000000001251262261713100265710ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E://foo//bar//baz//'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-10.js000066400000000000000000000001451262261713100266530ustar00rootroot00000000000000'use strict'; /** * 'c:/user/docs/letter.txt' */ module.exports = ['C:\\user\\docs\\Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-11.js000066400000000000000000000001351262261713100266530ustar00rootroot00000000000000'use strict'; /** * /user/docs/letter.txt' */ module.exports = ['/user/docs/Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-12.js000066400000000000000000000001141262261713100266510ustar00rootroot00000000000000'use strict'; /** * 'c:letter.txt' */ module.exports = ['C:Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-13.js000066400000000000000000000001631262261713100266560ustar00rootroot00000000000000'use strict'; /** * /server01/user/docs/letter.txt' */ module.exports = ['\\Server01\\user\\docs\\Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-14.js000066400000000000000000000001771262261713100266640ustar00rootroot00000000000000'use strict'; /** * /unc/server01/user/docs/letter.txt' */ module.exports = ['\\?\\UNC\\Server01\\user\\docs\\Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-15.js000066400000000000000000000001521262261713100266560ustar00rootroot00000000000000'use strict'; /** * /c:/user/docs/letter.txt' */ module.exports = ['\\?\\C:\\user\\docs\\Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-16.js000066400000000000000000000002251262261713100266600ustar00rootroot00000000000000'use strict'; /** * 'c:/user/docs/somefile.ext:alternate_stream_name' */ module.exports = ['C:\\user\\docs\\somefile.ext:alternate_stream_name'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-17.js000066400000000000000000000000741262261713100266630ustar00rootroot00000000000000'use strict'; /** * 'cwd' */ module.exports = ['./cwd'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-18.js000066400000000000000000000001211262261713100266550ustar00rootroot00000000000000'use strict'; /** * '/grandparent' */ module.exports = ['../../grandparent'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-2.js000066400000000000000000000001211262261713100265660ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E:/foo/bar/baz/'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-3.js000066400000000000000000000001231262261713100265710ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E://foo\\bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-4.js000066400000000000000000000001141262261713100265720ustar00rootroot00000000000000'use strict'; /** * 'foo/bar/baz' */ module.exports = ['foo\\bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-5.js000066400000000000000000000001161262261713100265750ustar00rootroot00000000000000'use strict'; /** * 'foo/bar/baz' */ module.exports = ['foo\\bar\\baz\\'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-6.js000066400000000000000000000001221262261713100265730ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E://foo/bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-7.js000066400000000000000000000001241262261713100265760ustar00rootroot00000000000000'use strict'; /** * 'e:/foo/bar/baz' */ module.exports = ['E:\\\\foo/bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-8.js000066400000000000000000000001151262261713100265770ustar00rootroot00000000000000'use strict'; /** * /foo/bar/baz' */ module.exports = ['//foo/bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/path-9.js000066400000000000000000000001161262261713100266010ustar00rootroot00000000000000'use strict'; /** * /foo/bar/baz' */ module.exports = ['//foo\\bar\\baz'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/short.js000066400000000000000000000001401262261713100266330ustar00rootroot00000000000000'use strict'; /** * /user/docs/letter.txt' */ module.exports = ['\\user\\docs\\Letter.txt'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/trailing.js000066400000000000000000000001341262261713100273100ustar00rootroot00000000000000'use strict'; /** * /user/docs/letter.txt' */ module.exports = ['a/b/c/d/e/f/g/', true];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/unix.js000066400000000000000000000001331262261713100264610ustar00rootroot00000000000000module.exports = ['/Users/jonschlinkert/dev/path-utils/normalize-path/benchmark/index.js'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/fixtures/win.js000066400000000000000000000001441262261713100262750ustar00rootroot00000000000000module.exports = ['C:\\Users\\jonschlinkert\\dev\\path-utils\\normalize-path\\benchmark\\index.js'];normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/benchmark/index.js000066400000000000000000000003061262261713100247360ustar00rootroot00000000000000'use strict'; var Suite = require('benchmarked'); var suite = new Suite({ result: true, fixtures: 'fixtures/{unix,win}.js', add: 'code/{current,while}.js', cwd: __dirname }); suite.run();normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/bower.json000066400000000000000000000012501262261713100233470ustar00rootroot00000000000000{ "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.", "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": "^0.1.1", "mocha": "*" }, "keywords": [ "backslash", "file", "filepath", "fp", "normalize", "path", "slash", "slashes", "trailing", "unix", "urix" ] }normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/index.js000066400000000000000000000006551262261713100230130ustar00rootroot00000000000000/*! * normalize-path * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License */ module.exports = function normalizePath(str, stripTrailing) { if (typeof str !== 'string') { throw new TypeError('expected a string'); } str = str.replace(/[\\\/]+/g, '/'); if (stripTrailing !== false) { str = str.replace(/\/$/, ''); } return str; }; normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/package.json000066400000000000000000000024251262261713100236310ustar00rootroot00000000000000{ "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.", "version": "2.0.1", "homepage": "https://github.com/jonschlinkert/normalize-path", "author": "Jon Schlinkert (https://github.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": { "benchmarked": "^0.1.1", "minimist": "^1.2.0", "mocha": "*" }, "keywords": [ "backslash", "file", "filepath", "fix", "forward", "fp", "fs", "normalize", "path", "slash", "slashes", "trailing", "unix", "urix" ], "verb": { "related": { "list": [ "rewrite-ext", "contains-path", "ends-with", "path-ends-with", "path-segments", "is-absolute", "is-relative", "parse-filepath", "unixify" ], "description": "Other useful libraries for working with paths in node.js:" } } } normalize-path-3ad522d516a41c4f4212c8a4bd5c8005ef62b382/test.js000066400000000000000000000066131262261713100226630ustar00rootroot00000000000000/*! * normalize-path * * Copyright (c) 2014-2015, 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:', function () { it('should normalize "E://foo//bar//baz"', function() { assert.equal(normalize('E://foo//bar//baz'), 'E:/foo/bar/baz'); }); it('should normalize "E://foo//bar//baz//"', function() { assert.equal(normalize('E://foo//bar//baz//'), 'E:/foo/bar/baz'); }); it('should normalize "E:/foo/bar/baz/"', function() { assert.equal(normalize('E:/foo/bar/baz/'), 'E:/foo/bar/baz'); }); it('should normalize "E://foo\\bar\\baz"', function() { assert.equal(normalize('E://foo\\bar\\baz'), 'E:/foo/bar/baz'); }); it('should normalize "foo\\bar\\baz"', function() { assert.equal(normalize('foo\\bar\\baz'), 'foo/bar/baz'); }); it('should normalize "foo\\bar\\baz\\"', function() { assert.equal(normalize('foo\\bar\\baz\\'), 'foo/bar/baz'); }); it('should normalize "E://foo/bar\\baz"', function() { assert.equal(normalize('E://foo/bar\\baz'), 'E:/foo/bar/baz'); }); it('should normalize "E:\\\\foo/bar\\baz"', function() { assert.equal(normalize('E:\\\\foo/bar\\baz'), 'E:/foo/bar/baz'); }); it('should normalize "foo/bar\\baz"', function() { assert.equal(normalize('//foo/bar\\baz'), '/foo/bar/baz'); }); it('should normalize "foo\\bar\\baz"', function() { assert.equal(normalize('//foo\\bar\\baz'), '/foo/bar/baz'); }); it('should normalize "C:\\user\\docs\\Letter.txt"', function() { assert.equal(normalize('C:\\user\\docs\\Letter.txt'), 'C:/user/docs/Letter.txt'); }); it('should normalize "user/docs/Letter.txt"', function() { assert.equal(normalize('/user/docs/Letter.txt'), '/user/docs/Letter.txt'); }); it('should normalize "C:Letter.txt"', function() { assert.equal(normalize('C:Letter.txt'), 'C:Letter.txt'); }); it('should normalize "Server01\\user\\docs\\Letter.txt"', function() { assert.equal(normalize('\\Server01\\user\\docs\\Letter.txt'), '/Server01/user/docs/Letter.txt'); }); it('should normalize "UNC\\Server01\\user\\docs\\Letter.txt"', function() { assert.equal(normalize('\\?\\UNC\\Server01\\user\\docs\\Letter.txt'), '/?/UNC/Server01/user/docs/Letter.txt'); }); it('should normalize "C:\\user\\docs\\Letter.txt"', function() { assert.equal(normalize('\\?\\C:\\user\\docs\\Letter.txt'), '/?/C:/user/docs/Letter.txt'); }); it('should normalize "C:\\user\\docs\\somefile.ext:alternate_stream_name"', function() { assert.equal(normalize('C:\\user\\docs\\somefile.ext:alternate_stream_name'), 'C:/user/docs/somefile.ext:alternate_stream_name'); }); it('should normalize "grandparent"', function() { assert.equal(normalize('../../grandparent'), '../../grandparent'); }); describe('when `false` is passed as the last argument:', function() { it('should not strip trailing slashes', function() { assert.equal(normalize('foo\\bar\\baz\\', false), 'foo/bar/baz/'); assert.equal(normalize('foo/bar/baz/', false), 'foo/bar/baz/'); assert.equal(normalize('./foo/bar/baz/', false), './foo/bar/baz/'); }); }); });