dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

BUG: Wrong result for Utilities.getRealPath() on Windows OS #577

Open wilsoncook opened 9 years ago

wilsoncook commented 9 years ago

an example:

db.load('e:\webroot\zx250\models\user.js');

it will try to load this path "e:\webroot\zx250\node_modules\q/e:\webroot\zx250\models\user.js" which is wrong, look into the code in lib/Utilities.js, at line 274, function getRealPath():

274  if (path_str[0] !== path.sep) {
275        path_str = cwd + "/" + path_str;
276  }

the value of path.sep is \, so it add the variable cwd to the prefix. This is on Windows 7 64bit, i can see that it would reproduce on all Win OS. So i just edit the codes for emergency:

274  if (path_str[0] !== path.sep && path_str.indexOf(':') === -1) { //Fix BUG, but not strict
275        path_str = cwd + "/" + path_str;
276  }