ui: fix codeLang-sub-select

This commit is contained in:
undefined committed 2021-05-12 00:07:07 +08:00
1 parent 41f6149359
commit 5fad63a3e1
4 files changed
+9 -7

No files matched your search

+6 -3
View File
@@ -1,8 +1,11 @@
/**
* @param {string} str
* @param {any} obj
* @returns {string}
*/
export default function substitute(str, obj) {
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
if (obj[key] !== undefined) {
return String(obj[key]);
}
if (obj[key] !== undefined) return obj[key].toString();
return `{${key}}`;
});
}