« get me outta code hell

data: language: support preserving value type in #sanitizeStringArg - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-29 16:02:01 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-30 13:23:08 -0400
commit8923fc4086ed66fa888edc6165c65e50c6afd94a (patch)
tree33c95b6806bfd41b6b34c7529579edd98f722c83 /src
parentec1ab18897d8dcd20d13fa5b5e1096b80a21ce95 (diff)
data: language: support preserving value type in #sanitizeStringArg
Behind an option, for now.
Diffstat (limited to 'src')
-rw-r--r--src/data/things/language.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/data/things/language.js b/src/data/things/language.js
index 4481af55..27bee3e4 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -255,7 +255,7 @@ export class Language extends Thing {
   // treated by the browser as a tag. This does *not* have an effect on actual
   // html.Tag objects, which are treated as sanitized by default (so that they
   // can be nested inside strings at all).
-  #sanitizeStringArg(arg) {
+  #sanitizeStringArg(arg, {preserveType = false} = {}) {
     const escapeHTML = CacheableObject.getUpdateValue(this, 'escapeHTML');
 
     if (!escapeHTML) {
@@ -263,7 +263,12 @@ export class Language extends Thing {
     }
 
     if (typeof arg !== 'string') {
-      return arg.toString();
+      // TODO: Preserving type will be the only behavior.
+      if (preserveType) {
+        return arg;
+      } else {
+        return arg.toString();
+      }
     }
 
     return escapeHTML(arg);