From bfebb22518dd0613d845ad4da765be2ed0513ee2 Mon Sep 17 00:00:00 2001 From: Samuel Hellawell Date: Tue, 10 Jan 2023 01:51:58 +0000 Subject: [PATCH] Fix name displayed as [object Object] depending on data --- package.json | 2 +- src/index.js | 4 +++- src/templates/credential.js | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9a2b544..d1b923c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@docknetwork/prettyvc", "description": "Render pretty verifiable credentials", - "version": "1.3.12", + "version": "1.3.13", "main": "lib/index.js", "license": "MIT", "repository": { diff --git a/src/index.js b/src/index.js index cfee5f2..02bfd6c 100644 --- a/src/index.js +++ b/src/index.js @@ -175,7 +175,9 @@ function extractNameFields(s) { function getSubjectName({ credentialSubject }, didMap) { const subjects = Array.isArray(credentialSubject) ? credentialSubject : [credentialSubject]; - return subjects.map((s) => s && mapDIDIfKnown(getObjectName(s, extractNameFields)), didMap).join(' & '); + return subjects.map((s) => s && mapDIDIfKnown(getObjectName(s, extractNameFields)), didMap) + .filter((s) => typeof s === 'string') + .join(' & '); } function getSubjectDocuments({ credentialSubject }) { diff --git a/src/templates/credential.js b/src/templates/credential.js index db68667..c431184 100644 --- a/src/templates/credential.js +++ b/src/templates/credential.js @@ -23,7 +23,11 @@ export default function TemplateCredential({

${sanitize(subjectName)}

- ` : ''} + ` : ` +

+ has issued a ${sanitize(title)} +

+ `} ${attributes.length ? `