fix base64 bug (#412)

* fix base64 bug

The Base64 table has Char '+' [https://en.wikipedia.org/wiki/Base64](https://en.wikipedia.org/wiki/Base64), it will turn to blank characters in url request, It will cause some error when  deserializeState the state.

* Fix encodeURIComponent for serialize
main
Shihua Ma 7 years ago committed by Michael Fix
parent 0525a9fcca
commit b1371508ed

@ -50,11 +50,13 @@ const reverseMappings = mappings.map(mapping =>
)
export const serializeState = state => {
const stateString = encodeURIComponent(JSON.stringify(state))
const stateString = JSON.stringify(state)
return typeof window !== 'undefined'
? btoa(stateString)
: Buffer.from(stateString).toString('base64')
return encodeURIComponent(
typeof window !== 'undefined'
? btoa(stateString)
: Buffer.from(stateString).toString('base64')
)
}
export const deserializeState = serializedState => {

Loading…
Cancel
Save