diff --git a/app/signal/index.js b/app/signal/index.js index 7b13d788d207837284b3a3c598f98c84d13797ff..a2f9758e36c2b43c12f62f7424696cd52e6994b7 100644 --- a/app/signal/index.js +++ b/app/signal/index.js @@ -306,7 +306,7 @@ const parseOutboundAttachment = inAttachment => ({ // string -> [boolean, string] const parseVerificationCode = verificationMessage => { - const matches = verificationMessage.match(/.*: (\d\d\d-\d\d\d)/) + const matches = verificationMessage.match(/.*: (\d\d\d-?\d\d\d)/) return isEmpty(matches) ? [false, verificationMessage] : [true, matches[1]] } diff --git a/test/unit/signal/index.spec.js b/test/unit/signal/index.spec.js index 397743df0686b0a4bda695869486f6d09b174208..8178ee64f8f896124889e11855fa6328e98e17e9 100644 --- a/test/unit/signal/index.spec.js +++ b/test/unit/signal/index.spec.js @@ -542,6 +542,13 @@ describe('signal module', () => { ]) }) + it('parses a signal verification code without a dassh from an sms message', () => { + expect(parseVerificationCode('Your Signal verification code: 123456')).to.eql([ + true, + '123456', + ]) + }) + it('returns an error from an sms message that is not a verification code', () => { expect(parseVerificationCode('JOIN')).to.eql([false, 'JOIN']) })