safeframe icon indicating copy to clipboard operation
safeframe copied to clipboard

Uncaught TypeError: data.indexOf is not a function in _handle_msg_from_outside method in host.js

Open joeyaza opened this issue 6 years ago • 5 comments

I get the above error as it expects data to be a string but in my case is coming in as an object from the PostMessage. And running .indexOf on a non-string throws an error. Is there any way to counter this? potentially, data could be stringified so its certain to be a string? or typeof data could be ascertained prior to make sure it is a string before running the indexOf method..

joeyaza avatar Nov 21 '18 14:11 joeyaza

Yeah the code was written before automatic JSON parsing of objects sent via postMessage started happening. Since the communication protocol is always expected to be a string internally I would do a typeof check and then reject the message if it's not a string.

seansd-zz avatar Nov 21 '18 16:11 seansd-zz

shall I change and make a PR ?

joeyaza avatar Nov 22 '18 11:11 joeyaza

sure go for it

seansd-zz avatar Nov 22 '18 16:11 seansd-zz

Any update here?

kevingilbert100 avatar May 30 '22 23:05 kevingilbert100

I have same issue. how can it be solve?

hotbrainy avatar Feb 14 '23 05:02 hotbrainy