Skip to content

Convert a windows file path to a unix-style file path.

License

Notifications You must be signed in to change notification settings

BendingBender/unixify

This branch is 1 commit ahead of jonschlinkert/unixify:master.

Repository files navigation

unixify NPM version NPM monthly downloads NPM total downloads Linux Build Status

Convert Windows file paths to unix paths.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save unixify

Usage

const unixify = require('unixify');
unixify(filepath[, stripTrailingSlash]);

Strips leading drive letters and dot-slash (./)

unixify('.\\one\\two\\three');  //=> 'one/two/three'
unixify('./one/two/three');     //=> 'one/two/three'
unixify('C:\\one\\two\\three'); //=> '/one/two/three'
unixify('\\one\\two\\three');   //=> '/one/two/three'

Normalizes path separators to forward slashes

unixify('one\\two\\three');      //=> 'one/two/three'
unixify('\\one\\two\\three');    //=> '/one/two/three'
unixify('C:\\one\\two\\three');  //=> '/one/two/three'

Combines multiple consecutive slashes

unixify('one//two//////three'),     //=> 'one/two/three'
unixify('\\one\\two\\//three');     //=> '/one/two/three'
unixify('C:\\//one\\two\\//three'); //=> '/one/two/three'

Strips trailing slashes by default

unixify('one//two//////three//'), //=> 'one/two/three'
unixify('C:\\one\\two\\three\\'); //=> '/one/two/three'

Keep trailing slashes

By passing false as the second argument

unixify('one//two//////three//', false), //=> 'one/two/three/'
unixify('C:\\one\\two\\three\\', false); //=> '/one/two/three/'

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

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:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

Other useful libraries for working with paths in node.js:

Author

Jon Schlinkert

License

Copyright © 2021, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on January 06, 2021.

About

Convert a windows file path to a unix-style file path.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%