From 3e522c3ef0ad37aae4e7fddf4e3302c084c5e69f Mon Sep 17 00:00:00 2001 From: SLaks Date: Thu, 9 May 2013 13:25:17 -0300 Subject: [PATCH] Force all paths to use forward slashes Don't expose Windows-style paths in the browser. (especially since the browser-side `path` module won't recognize backslahses) I am ignoring the possibility of a Linux path with a `\` in it. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1bde70c..11f63d5 100644 --- a/index.js +++ b/index.js @@ -76,11 +76,11 @@ module.exports = function (files, opts) { globals.global = 'window'; } if (scope.globals.implicit.indexOf('__filename') >= 0) { - var file = '/' + path.relative(basedir, row.id); + var file = '/' + path.relative(basedir, row.id).replace(/\\/g, '/'); globals.__filename = JSON.stringify(file); } if (scope.globals.implicit.indexOf('__dirname') >= 0) { - var dir = path.dirname('/' + path.relative(basedir, row.id)); + var dir = path.dirname('/' + path.relative(basedir, row.id)).replace(/\\/g, '/'); globals.__dirname = JSON.stringify(dir); }