diff --git a/packages/cozy-pouch-link/examples/periodic-sync/index.js b/packages/cozy-pouch-link/examples/periodic-sync/index.js index c42ba7bd3b..ecfa6b5990 100755 --- a/packages/cozy-pouch-link/examples/periodic-sync/index.js +++ b/packages/cozy-pouch-link/examples/periodic-sync/index.js @@ -88,7 +88,7 @@ class App extends React.Component { replicationDelay: 2 * 1000, getReplicationURL: this.getReplicationURL, onError: err => { - if (err.error == 'code=400, message=Expired token') { + if (/Expired token/.test(err.error)) { console.log('You need to refresh the token') } this.setState({ error: err.error }) diff --git a/packages/cozy-pouch-link/src/CozyPouchLink.js b/packages/cozy-pouch-link/src/CozyPouchLink.js index 19344d6e5e..db60528de2 100644 --- a/packages/cozy-pouch-link/src/CozyPouchLink.js +++ b/packages/cozy-pouch-link/src/CozyPouchLink.js @@ -53,8 +53,9 @@ export const getReplicationURL = (uri, token, doctype) => { } const doNothing = () => {} +const expiredTokenError = /Expired token/ export const isExpiredTokenError = pouchError => { - return pouchError.error === 'code=400, message=Expired token' + return expiredTokenError.test(pouchError.error) } const normalizeAll = (docs, doctype) => {