blob: dad479b9dd2d34da6bbfbd3ab68baed7a2a85369 [file] [log] [blame]
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */
import path from 'node:path';
/**
* Normalize a file path for cross-platform compatibility
* @param {string} p The file path
* @param {*} [testPath] The path handler
* @returns {string} The normalized path
*/
export const normalizePathInternal = (p, testPath = path) => {
if (testPath.sep === '/') {
return p;
}
return p.replace(/\\/gi, '/');
};
/**
* Normalize a file path for cross-platform compatibility
* @param {string} p The file path
* @returns {string} The normalized path
*/
export default (p) => normalizePathInternal(p, path);