Skip to content

Commit

Permalink
SandBox, bugfix: require('..') is not equal require('../') on Windows…
Browse files Browse the repository at this point in the history
… XP;
  • Loading branch information
xicilion committed Aug 9, 2017
1 parent c977e48 commit b1828ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions fibjs/src/sandbox/SandBox_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ void _run(const v8::FunctionCallbackInfo<v8::Value>& args)
exlib::string strPath;

path_base::dirname(*v8::String::Utf8Value(path), strPath);
if (strPath.length())
strPath += PATH_SLASH;
id = strPath + id;
if (strPath.length()) {
resolvePath(strPath, id);
id = strPath;
}
}

hr = sbox->run(id, argv);
Expand Down
17 changes: 9 additions & 8 deletions fibjs/src/sandbox/SandBox_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ result_t SandBox::resolvePackage(v8::Local<v8::Object> mods, exlib::string& fnam
exlib::string buf;
obj_ptr<Buffer_base> bin;

fname1 = fname + PATH_SLASH + "package.json";
fname1 = fname;
resolvePath(fname1, "package.json");
hr = loadFile(fname1, bin);
if (hr < 0)
return CALL_E_FILE_NOT_FOUND;
Expand Down Expand Up @@ -159,7 +160,8 @@ result_t SandBox::resolveFile(exlib::string& fname, obj_ptr<Buffer_base>& data,
if (hr != CALL_E_FILE_NOT_FOUND)
return hr;

fname1 = fname + PATH_SLASH + "index";
fname1 = fname;
resolvePath(fname1, "index");
hr = resolveFile(_mods, fname1, data, retVal);
if (hr >= 0) {
fname = fname1;
Expand All @@ -173,7 +175,7 @@ result_t SandBox::resolveFile(exlib::string& fname, obj_ptr<Buffer_base>& data,
return hr;
}

fname1 = fname1 + PATH_SLASH + "index";
resolvePath(fname1, "index");
hr = resolveFile(_mods, fname1, data, retVal);
if (hr >= 0) {
fname = fname1;
Expand Down Expand Up @@ -233,11 +235,10 @@ result_t SandBox::resolveModule(exlib::string base, exlib::string& id, obj_ptr<B
base = fname;

if (fname.length())
fname += PATH_SLASH;

fname += "node_modules";
fname += PATH_SLASH;
fname += id;
resolvePath(fname, "node_modules");
else
fname = "node_modules";
resolvePath(fname, id);

hr = resolveFile(fname, data, &retVal);
if (hr != CALL_E_FILE_NOT_FOUND && hr != CALL_E_PATH_NOT_FOUND) {
Expand Down

0 comments on commit b1828ad

Please sign in to comment.