Permalink
Browse files

Fix the `path.sep` replacement of node-haste for Windows

Summary:
Fix the `path.sep` replacement for Windows, currently it just replace one segment:

```js
// Result: './lib/random\random-byte.js'
'./lib\\random\\random-byte.js'.replace(path.sep, '/')
```

Change to regex will work fine:

```js
// Result: './lib/random/random-byte.js' (correct)
'./lib\\random\\random-byte.js'.replace(new RegExp('\\' + path.sep, 'g'), '/')
```
Closes #11641

Differential Revision: D4368402

fbshipit-source-id: 46f456359d1cd2ca790881773e8a76af8616cd21
  • Loading branch information...
jhen0409 authored and facebook-github-bot committed Dec 27, 2016
1 parent 199d640 commit 2249af16b7ee84d3e25ca7e827e725c7994f936d
@@ -77,7 +77,7 @@ module.exports = class Package {
let relPath = './' + path.relative(this.root, name);
if (path.sep !== '/') {
relPath = relPath.replace(path.sep, '/');
relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
}
let redirect = replacements[relPath];
@@ -97,7 +97,7 @@ class Package {
let relPath = './' + path.relative(this.root, name);
if (path.sep !== '/') {
relPath = relPath.replace(path.sep, '/');
relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
}
let redirect = replacements[relPath];

1 comment on commit 2249af1

@waqas19921

This comment has been minimized.

Show comment
Hide comment
@waqas19921

waqas19921 Feb 7, 2017

is this commit included in 0.41?
i have updated to version 0.41 but it does not have that change.

waqas19921 commented on 2249af1 Feb 7, 2017

is this commit included in 0.41?
i have updated to version 0.41 but it does not have that change.

Please sign in to comment.