We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
引用自richard-chou的笔记。
setCookie(cookieStr) { const oldCookieJson = this.cookieToJson(wx.getStorageSync('cookie')) const newCookieJson = this.multiCookieStrToArray(cookieStr).map((cookieString) => { return this.cookieToJson(cookieString) }).reduce((result, value) => { return Object.assign({}, result, value) }, oldCookieJson) const newCookieStr = objectEntries(newCookieJson).map(value => value.join('=')).join(';') wx.setStorageSync('cookie', newCookieStr) }, cookieToJson(cookieStr) { return cookieStr.split(';') .filter(value => value.trim()) .map(value => { const equlIndex = value.indexOf('=') return [ value.substr(0, equlIndex), value.substr(equlIndex + 1, value.length) ] }).reduce((result, value) => { return Object.assign({}, result, { [value[0]]: value[1] }) }, {}) }, multiCookieStrToArray(cookieStr) { // 应对 http 响应有多次 set-cookie 的情况 return cookieStr.split('Path=/,') },
The text was updated successfully, but these errors were encountered:
No branches or pull requests
引用自richard-chou的笔记。
The text was updated successfully, but these errors were encountered: