3

I'm using supertest and trying to get the cookie data cleanly

agent.post('/login').send('username:u','password:p').end(function(err, res) {
    agent.cookie = res.req._headers.cookie;
});

But to cookie data I get is jumbled up

connect.sid=s%3Afc20GaiFXGNju1rxqDSOEiA4.W3XfTacI0xhk4gQ9Bdh1LLC%2FlhjnAwVmQkUX%2F7%2FJEAo

instead of cleanly like this (and the above is even longer for some reason)

{ 'connect.sid': 'T0jrnU09DzCYN68FsgspuY5g' }

How do I get the latter?

laggingreflex
  • 32,948
  • 35
  • 141
  • 196

1 Answers1

2
require('cookie').parse(decodeURIComponent(cookie))
laggingreflex
  • 32,948
  • 35
  • 141
  • 196