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