Skip to content

Commit

Permalink
Decode base64-encoded Text Attachments (#308)
Browse files Browse the repository at this point in the history
* introduce fix as described in PR 297

* fix test

---------

Co-authored-by: Max Schluer <[email protected]>
  • Loading branch information
mschluer and Max Schluer authored Jan 15, 2024
1 parent 20c338c commit c1278c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/generate-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,17 @@ function generateReport(options) {
scenario.steps.forEach((step) => {
if (step.embeddings !== undefined) {
step.attachments = [];

step.embeddings.forEach((embedding, embeddingIndex) => {
/* Decode Base64 for Text-ish attachements */
if(
embedding.mime_type === 'application/json' ||
embedding.mime_type === 'text/html' ||
embedding.mime_type === 'text/plain'
) {
embedding.data = Buffer.from(embedding.data.toString(), 'base64')
}

/* istanbul ignore else */
if (
embedding.mime_type === 'application/json' ||
Expand Down

0 comments on commit c1278c6

Please sign in to comment.