为了账号安全,请及时绑定邮箱和手机立即绑定

React Native 格式 cookie

React Native 格式 cookie

catspeake 2023-10-20 17:30:51
我有一个看起来像这样的 cookie:{"SSOsess":"300|c6dc6d60ebebf0891004353352f24b77","RTBk":"300|451706000c67a37dfe5bebe0b5d26278","ph02RPNCiscoASA":"application.api.randwebsite.com","ph03RPNCiscoASA":"application.client.randwebsite.com"}是否有任何库可以帮助我将字符串格式化为以下内容:'SSOsess=300|c6dc6d60ebebf0891004353352f24b77; RTBk=300|451706000c67a37dfe5bebe0b5d26278; ph02RPNCiscoASA=application.api.randwebsite.com; ph03RPNCiscoASA=application.client.randwebsite.com'我一直在查看set-cookie-parser但看起来它不包含任何有用的功能。
查看完整描述

1 回答

?
小唯快跑啊

TA贡献1863条经验 获得超2个赞

尝试这个。


let cookie = JSON.stringify({"SSOsess":"300|c6dc6d60ebebf0891004353352f24b77","RTBk":"300|451706000c67a37dfe5bebe0b5d26278","ph02RPNCiscoASA":"application.api.randwebsite.com","ph03RPNCiscoASA":"application.client.randwebsite.com"})


var output = cookie.split(":").join("=").split(',').join("; ")

output = "'"+output.substring(1,output.length-1).replace(/"/g, "")+"'"


console.log(output)

//输出


'SSOsess=300|c6dc6d60ebebf0891004353352f24b77; RTBk=300|451706000c67a37dfe5bebe0b5d26278; ph02RPNCiscoASA=application.api.randwebsite.com; ph03RPNCiscoASA=application.client.randwebsite.com'



查看完整回答
反对 回复 2023-10-20
  • 1 回答
  • 0 关注
  • 97 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信