From e62f2f8f7721e723184fecab2be08bda358c7ade Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 25 Feb 2025 15:36:15 +0200 Subject: [PATCH] Also allow arrays of UnsafeXML --- Makefile | 4 ++++ src/stanza.js | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6253f72..11b73be 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,10 @@ prettier: node_modules check:: node_modules eslint dist npm ci && npm run test +.PHONY: test +test: + make check + .PHONY: serve serve: node_modules $(HTTPSERVE) -p $(HTTPSERVE_PORT) diff --git a/src/stanza.js b/src/stanza.js index 3936024..afc5489 100644 --- a/src/stanza.js +++ b/src/stanza.js @@ -96,7 +96,13 @@ export class Stanza extends Builder { acc + str + (Array.isArray(value) - ? value.map((v) => (v instanceof Builder ? v : xmlescape(v.toString()))).join('') + ? value + .map((v) => + v instanceof UnsafeXML || v instanceof Builder + ? v + : xmlescape(v.toString()) + ) + .join('') : value instanceof UnsafeXML || value instanceof Builder ? value : xmlescape((value ?? '').toString()))