From 0056773769b671a0023b996e211f26a5ef9c3618 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 23 Mar 2016 15:23:13 -0700 Subject: [PATCH] fix(signatures): Fix signature switching between accounts in composer --- .../composer-signature/lib/signature-utils.es6 | 6 +++--- .../spec/signature-composer-extension-spec.es6 | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal_packages/composer-signature/lib/signature-utils.es6 b/internal_packages/composer-signature/lib/signature-utils.es6 index d1565d005..b3c2ca19f 100644 --- a/internal_packages/composer-signature/lib/signature-utils.es6 +++ b/internal_packages/composer-signature/lib/signature-utils.es6 @@ -1,7 +1,7 @@ export default { applySignature(body, signature) { - // https://regex101.com/r/nC0qL2/1 - const signatureRegex = /[^]*<\/signature>/; + // https://regex101.com/r/nC0qL2/2 + const signatureRegex = /(){0,2}[^]*<\/signature>/; let newBody = body; let paddingBefore = ''; @@ -23,6 +23,6 @@ export default { const contentBefore = newBody.slice(0, insertionPoint); const contentAfter = newBody.slice(insertionPoint); - return `${contentBefore}${paddingBefore}${signature}${paddingAfter}${contentAfter}`; + return `${contentBefore}${paddingBefore}${signature}${paddingAfter}${contentAfter}`; }, }; diff --git a/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 b/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 index 913e26bc5..7094e4324 100644 --- a/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 +++ b/internal_packages/composer-signature/spec/signature-composer-extension-spec.es6 @@ -38,7 +38,7 @@ describe("SignatureComposerExtension", () => { SignatureComposerExtension.prepareNewDraft({draft: a}); expect(a.body).toEqual(`This is a test! ${TEST_SIGNATURE}
Hello world
`); SignatureComposerExtension.prepareNewDraft({draft: b}); - expect(b.body).toEqual(`This is a another test.

${TEST_SIGNATURE}
`); + expect(b.body).toEqual(`This is a another test.

${TEST_SIGNATURE}`); }); const scenarios = [ @@ -50,17 +50,17 @@ describe("SignatureComposerExtension", () => { { name: 'Populated signature div', body: `This is a test!

SIG
`, - expected: `This is a test!

${TEST_SIGNATURE}
`, + expected: `This is a test!

${TEST_SIGNATURE}`, }, { name: 'Empty signature div', body: 'This is a test! ', - expected: `This is a test!

${TEST_SIGNATURE}
`, + expected: `This is a test!

${TEST_SIGNATURE}`, }, { name: 'With newlines', - body: 'This is a test! \n
\n
SIG
\n
', - expected: `This is a test!

${TEST_SIGNATURE}
`, + body: 'This is a test!
\n
\n
SIG
\n
', + expected: `This is a test!


${TEST_SIGNATURE}`, }, ]