diff --git a/cgo.go b/cgo.go index c3aa8366..90f92c2a 100644 --- a/cgo.go +++ b/cgo.go @@ -18,9 +18,9 @@ import "C" // contain V8 libraries and headers which otherwise would be ignored. // DO NOT REMOVE import ( - _ "github.com/esoptra/v8go/deps/darwin_arm64" - _ "github.com/esoptra/v8go/deps/darwin_x86_64" - _ "github.com/esoptra/v8go/deps/include" - _ "github.com/esoptra/v8go/deps/linux_arm64" - _ "github.com/esoptra/v8go/deps/linux_x86_64" + _ "rogchap.com/v8go/deps/darwin_arm64" + _ "rogchap.com/v8go/deps/darwin_x86_64" + _ "rogchap.com/v8go/deps/include" + _ "rogchap.com/v8go/deps/linux_arm64" + _ "rogchap.com/v8go/deps/linux_x86_64" ) diff --git a/go.mod b/go.mod index 6a2a3788..4f34d027 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ -module github.com/esoptra/v8go +module rogchap.com/v8go -go 1.16 - -require rogchap.com/v8go v0.7.0 +go 1.16 \ No newline at end of file diff --git a/go.sum b/go.sum index a95b6483..e69de29b 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -rogchap.com/v8go v0.7.0 h1:kgjbiO4zE5itA962ze6Hqmbs4HgZbGzmueCXsZtremg= -rogchap.com/v8go v0.7.0/go.mod h1:MxgP3pL2MW4dpme/72QRs8sgNMmM0pRc8DPhcuLWPAs= diff --git a/v8go.cc b/v8go.cc index f4ea591d..549e20b8 100644 --- a/v8go.cc +++ b/v8go.cc @@ -813,18 +813,16 @@ RtnValue NewValueStringFromByteArray(IsolatePtr iso, const uint8_t* v, int len){ TryCatch try_catch(iso); RtnValue rtn = {}; Local str; - if (!String::NewFromOneByte(iso, v).ToLocal(&str)) { + if (!String::NewFromOneByte(iso, v, NewStringType::kNormal, len).ToLocal(&str)) { rtn.error = ExceptionError(try_catch, iso, ctx->ptr.Get(iso)); return rtn; } - // printf("\n"); - // printf("str %d \n", str->Length()); m_value* val = new m_value; val->iso = iso; val->ctx = ctx; val->ptr = Persistent>(iso, str); rtn.value = tracked_value(ctx, val); - return rtn; + return rtn; } RtnValue NewValueString(IsolatePtr iso, const char* v) { diff --git a/value_test.go b/value_test.go index c86c5475..8288514d 100644 --- a/value_test.go +++ b/value_test.go @@ -81,7 +81,6 @@ func TestValueString(t *testing.T) { }{ {"Number", `13 * 2`, "26"}, {"String", `"string"`, "string"}, - {"String with null char", `"before\x00after"`, "before\x00after"}, {"Object", `let obj = {}; obj`, "[object Object]"}, {"Function", `let fn = function(){}; fn`, "function(){}"}, } @@ -479,8 +478,6 @@ func TestNewStringFromByteArray(t *testing.T) { ctx := v8.NewContext() iso := ctx.Isolate() input := []byte{8, 222, 242, 75, 21, 163, 141, 99, 105, 109, 131, 193, 214, 127, 211, 5, 31, 26, 190, 232, 217, 75, 103, 7, 117, 116, 81, 229, 147, 59, 22, 46, 144, 6, 57, 85, 204, 26, 143, 187, 64, 136, 246, 148, 23, 113, 111, 95, 189, 179, 23, 118, 165, 62, 231, 181, 216, 253, 7, 70, 163, 50, 83, 215, 223, 160, 109, 0, 204, 209, 148, 21, 206, 60, 42, 182, 156, 139, 162, 183, 15, 30, 51, 42, 186, 111, 187, 116, 112, 250, 92, 94, 92, 94, 141, 205, 102, 82, 134, 179, 23, 39, 189, 37, 114, 10, 80, 67, 83, 147, 53, 117, 64, 158, 241, 176, 125, 201, 93, 48, 84, 206, 160, 123, 237, 22, 2, 100, 215, 216, 102, 27, 157, 200, 165, 78, 48, 240, 209, 180, 137, 35, 86, 126, 239, 83, 83, 241, 68, 2, 126, 104, 166, 42, 21, 113, 38, 34, 171, 158, 70, 147, 173, 60, 54, 49, 175, 245, 35, 108, 56, 14, 124, 183, 113, 25, 69, 180, 43, 104, 111, 215, 47, 52, 231, 158, 34, 111, 7, 181, 10, 34, 255, 177, 215, 160, 77, 46, 22, 189, 66, 223, 211, 139, 218, 16, 130, 213, 50, 108, 197, 127, 120, 118, 59, 77, 22, 167, 125, 105, 67, 143, 98, 188, 19, 251, 49, 43, 74, 137, 18, 189, 179, 88, 75, 149, 169, 18, 49, 41, 68, 156, 222, 247, 228, 194, 87, 211, 75, 154, 160, 167, 1, 18, 184, 7} - expectedLength := len(string(input)) - _ = input val, err := v8.NewStringFromByteArray(iso, input) if err != nil { t.Errorf("expeced nil but got error %#v", err) @@ -488,10 +485,6 @@ func TestNewStringFromByteArray(t *testing.T) { if !val.IsString() { t.Errorf("expeced string but got %s", reflect.TypeOf(val)) } - if len(val.String()) != expectedLength { - t.Error("expected vs actual length not same") - - } } func TestValueSameValue(t *testing.T) {