sdk-js icon indicating copy to clipboard operation
sdk-js copied to clipboard

Evaluation context not being encoded on Edge browsers

Open amorimjuliana opened this issue 5 years ago • 0 comments

🐞 Bug report

On Edge browsers, the query-string parameter "context" appended to the evaluation's endpoint is a malformed JSON, which results in evaluation error.

User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362

Example of a request URL: http://api.croct.io/client/web/evaluate?expression=true&context=%7B%22page%22:%7B%22title%22:%22FooTitle%22,%22url%22:%22https://www.foo.com.br/%22,%22referrer%22:%22https://www.bar.com/,%22timezone%22:%22America/Sao_Paulo%22%7D

Evaluation result:

{
    detail: "The query-string parameter "context" is an invalid JSON-formatted string or cannot be deserialized."
    type: "https://croct.help/api/evaluation#malformed-context"
    title: "The context is malformed."
    status: 400
}

Expected behavior

After encoding, the request URL should be: http://api.croct.io/client/web/evaluate?expression=true&context=%7B%22page%22:%7B%22title%22:%22FooTitle%22,%22url%22:%22https%3A%2F%2Fwww.foo.com.br%2F%22,%22referrer%22:%22https%3A%2F%2Fwww.bar.com.br%2F,%22timezone%22:%22America/Sao_Paulo%22%7D

amorimjuliana avatar Sep 28 '20 21:09 amorimjuliana