From 6e5318faa7739a0ca012b495365bbb8cb805f16f Mon Sep 17 00:00:00 2001 From: coderiaser Date: Mon, 23 Mar 2026 23:47:24 +0200 Subject: [PATCH] fix: client: modules: config: input: quote --- client/modules/config/input.js | 24 ++++++++++++++++-------- client/modules/config/input.spec.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 client/modules/config/input.spec.js diff --git a/client/modules/config/input.js b/client/modules/config/input.js index 430f7e51..34a4be69 100644 --- a/client/modules/config/input.js +++ b/client/modules/config/input.js @@ -1,7 +1,9 @@ -import currify from 'currify'; +import {encode} from '#common/entity'; -const isType = currify((type, object, name) => type === typeof object[name]); -const isBool = isType('boolean'); +const isBool = (a) => typeof a === 'boolean'; +const isString = (a) => typeof a === 'string'; + +const {keys} = Object; export function getElementByName(selector, element) { const str = `[data-name="js-${selector}"]`; @@ -19,13 +21,19 @@ export const getName = (element) => { export const convert = (config) => { const result = config; - const array = Object.keys(config); - const filtered = array.filter(isBool(config)); - - for (const name of filtered) { + for (const name of keys(config)) { const item = config[name]; - result[name] = setState(item); + + if (isBool(item)) { + result[name] = setState(item); + continue; + } + + if (isString(item)) { + result[name] = encode(item); + continue; + } } return result; diff --git a/client/modules/config/input.spec.js b/client/modules/config/input.spec.js new file mode 100644 index 00000000..47fe88c5 --- /dev/null +++ b/client/modules/config/input.spec.js @@ -0,0 +1,16 @@ +import {test} from 'supertape'; +import {convert} from './input.js'; + +test('cloudcmd: client: config: input: convert', (t) => { + const result = convert({ + name: 'hello ', + }); + + const expected = { + name: 'hello <world>', + }; + + t.deepEqual(result, expected); + t.end(); +}); +