source: trip-planner-front/node_modules/canonical-path/index.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 694 bytes
Line 
1var path = require('path');
2var slashRegex = /\\/g;
3
4function canonical(p) {
5 return p.replace(slashRegex, '/');
6}
7
8function wrapWithCanonical(fn) {
9 return function() {
10 return canonical(fn.apply(path, arguments));
11 };
12}
13
14// Wrap the functions that return a path
15var toChange = ['normalize', 'join', 'resolve', 'relative', 'dirname', 'format'];
16toChange.forEach(function(fn) {
17 module.exports[fn] = wrapWithCanonical(path[fn]);
18});
19// and leave the rest alone
20var toLeave = ['basename', 'delimiter', 'extname', 'isAbsolute', 'parse', 'sep'];
21toLeave.forEach(function(prop) {
22 module.exports[prop] = path[prop];
23});
24
25module.exports.original = path;
26module.exports.canonical = canonical;
Note: See TracBrowser for help on using the repository browser.