Skip to content

Commit 9c6f487

Browse files
author
Mihail Slavchev
authored
Merge pull request #674 from NativeScript/slavchev/add-origin-fileshema
add file:// schema to script origin
2 parents 7460511 + bd8e385 commit 9c6f487

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

runtime/src/main/jni/CallbackHandlers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,13 @@ void CallbackHandlers::NewThreadCallback(const v8::FunctionCallbackInfo<v8::Valu
900900
auto isolate = thiz->GetIsolate();
901901

902902
auto currentExecutingScriptName = StackTrace::CurrentStackTrace(isolate, 1, StackTrace::kScriptName)->GetFrame(0)->GetScriptName();
903-
904903
auto currentExecutingScriptNameStr = ArgConverter::ConvertToString(currentExecutingScriptName);
905-
906904
auto lastForwardSlash = currentExecutingScriptNameStr.find_last_of("/");
907-
908905
auto currentDir = currentExecutingScriptNameStr.substr(0, lastForwardSlash + 1);
906+
string fileSchema("file://");
907+
if (currentDir.compare(0, fileSchema.length(), fileSchema) == 0) {
908+
currentDir = currentDir.substr(fileSchema.length());
909+
}
909910

910911
auto workerPath = ArgConverter::ConvertToString(args[0]->ToString(isolate));
911912

runtime/src/main/jni/ModuleInternal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ Local<Script> ModuleInternal::LoadScript(Isolate *isolate, const string& path, c
400400
//
401401
auto cacheData = TryLoadScriptCache(path);
402402

403-
ScriptOrigin origin(fullRequiredModulePath);
403+
auto fullRequiredModulePathWithSchema = ArgConverter::ConvertToV8String(isolate, "file://" + path);
404+
ScriptOrigin origin(fullRequiredModulePathWithSchema);
404405
ScriptCompiler::Source source(scriptText, origin, cacheData);
405406
ScriptCompiler::CompileOptions option = ScriptCompiler::kNoCompileOptions;
406407

test-app/app/src/main/assets/app/tests/exceptionHandlingTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ describe("Tests exception handling ", function () {
336336
expect(exceptionCaught).toBe(true);
337337
expect(errMsg).toContain("Cannot compile /data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js");
338338
expect(errMsg).toContain("SyntaxError: Unexpected token =");
339-
expect(errMsg).toContain("File: \"/data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js, line: 3, column: 10");
339+
expect(errMsg).toContain("File: \"file:///data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js, line: 3, column: 10");
340340

341341

342342

0 commit comments

Comments
 (0)