« get me outta code hell

data: language: stringify numbers and booleans in particular - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-29 16:51:57 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-30 13:23:08 -0400
commit7c47a5a4cae560a8105d2044f18fbf448901252b (patch)
treefc14829beffa61c2690cd64a71dc44014034d241 /src/data
parentb4e8afb733cf191b3b5333f7aafddf0802d04b39 (diff)
data: language: stringify numbers and booleans in particular
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/language.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/data/things/language.js b/src/data/things/language.js
index f8fe0106..0baea81d 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -283,10 +283,16 @@ export class Language extends Thing {
       throw new Error(`escapeHTML unavailable`);
     }
 
-    if (typeof arg === 'string') {
-      return escapeHTML(arg);
-    } else {
-      return arg;
+    switch (typeof arg) {
+      case 'string':
+        return escapeHTML(arg);
+
+      case 'number':
+      case 'boolean':
+        return arg.toString();
+
+      default:
+        return arg;
     }
   }