mirror of https://github.com/waku-org/js-waku.git
Ensure Uint8Array is passed to utf-8 conversion function
Proto unexpectedly returns an `Array<number>`.
This commit is contained in:
parent
52009b7be9
commit
49998c02bd
|
@ -252,12 +252,12 @@ export class WakuMessage {
|
|||
}
|
||||
|
||||
get payloadAsUtf8(): string {
|
||||
if (!this.proto.payload) {
|
||||
if (!this.payload) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
return bytesToUtf8(this.proto.payload);
|
||||
return bytesToUtf8(this.payload);
|
||||
} catch (e) {
|
||||
dbg("Could not decode byte as UTF-8", e);
|
||||
return "";
|
||||
|
@ -265,7 +265,10 @@ export class WakuMessage {
|
|||
}
|
||||
|
||||
get payload(): Uint8Array | undefined {
|
||||
return this.proto.payload;
|
||||
if (this.proto.payload) {
|
||||
return new Uint8Array(this.proto.payload);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
get contentTopic(): string | undefined {
|
||||
|
|
Loading…
Reference in New Issue