diff --git a/src/openpgp.js b/src/openpgp.js index 0a5cacf3..658a52be 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -391,7 +391,11 @@ function formatUserIds(options) { if (!util.isString(id.name) || (id.email && !util.isEmailAddress(id.email))) { throw new Error('Invalid user id format'); } - return id.name + ' <' + id.email + '>'; + id.name = id.name.trim(); + if (id.name.length > 0) { + id.name += ' '; + } + return id.name + '<' + id.email + '>'; }); return options; } diff --git a/src/util.js b/src/util.js index 32f22445..b329d84b 100644 --- a/src/util.js +++ b/src/util.js @@ -51,7 +51,7 @@ export default { if (!this.isString(data)) { return false; } - return / $/.test(data); + return /$/.test(data); }, /**