Skip to main content

Convert Windows file paths to Unix paths in Node.js.

/*!
 * unixify - Convert Windows file paths to unix paths.
 *
 * https://github.com/jonschlinkert/unixify
 *
 * Copyright (c) 2014, 2017, Jon Schlinkert.
 * Released under the MIT License.
 *
 * @example
 * var unixify = require('unixify');
 * unixify(filepath[, stripTrailingSlash]);
 */

"use strict";

var normalizePath = require("normalize-path");

module.exports = function unixify(filepath, stripTrailing) {
  filepath = normalizePath(filepath, stripTrailing);
  return filepath.replace(/^([a-zA-Z]+:|\.\/)/, "");
};