diff --git a/tests/commonjs_source_naming.phpt b/tests/commonjs_source_naming.phpt new file mode 100644 index 0000000..b57acfa --- /dev/null +++ b/tests/commonjs_source_naming.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test V8Js::setModuleLoader : Module source naming +--SKIPIF-- + +--FILE-- +setModuleLoader(function($module) { + // return code with syntax errors to provoke script exception + return "foo(blar);"; +}); + +try { + $v8->executeString($JS, 'commonjs_source_naming.js'); +} catch (V8JsScriptException $e) { + var_dump($e->getJsFileName()); +} +?> +===EOF=== +--EXPECT-- +string(7) "foo/bar" +===EOF=== diff --git a/v8js_methods.cc b/v8js_methods.cc index ed488b2..889a707 100644 --- a/v8js_methods.cc +++ b/v8js_methods.cc @@ -326,7 +326,7 @@ V8JS_METHOD(require) // Enter the module context v8::Context::Scope scope(context); // Set script identifier - v8::Local sname = V8JS_SYM("require"); + v8::Local sname = V8JS_SYM(normalised_module_id); v8::Local source = V8JS_STRL(Z_STRVAL_P(module_code), Z_STRLEN_P(module_code)); zval_ptr_dtor(&module_code);