@appolo/utils
Advanced tools
Comparing version 8.0.20 to 8.0.21
@@ -25,2 +25,11 @@ "use strict"; | ||
} | ||
static replaceFormatJson(str, data) { | ||
str = (str || "").replace(/\"\$\{([\w\.\_\:]*)\}\"/gm, (_m, key) => { | ||
let spread = key.split(":"), type = spread[1] || ""; | ||
key = spread[0]; | ||
let value = data.hasOwnProperty(key) ? ((!data[key] && data[key] !== false) ? "" : data[key]) : ""; | ||
return type == "number" ? (parseFloat(value) || 0).toString() : (type == "boolean" ? Boolean(value).toString() : `"${value}"`); | ||
}); | ||
return Strings.replaceFormat(str, data); | ||
} | ||
static sanitizeString(str) { | ||
@@ -27,0 +36,0 @@ // u200B is the hex equivalent of unicode 8203 and it will fuck with our encoding function in the ad server |
@@ -29,2 +29,18 @@ import {Functions} from "../index"; | ||
public static replaceFormatJson(str: string, data: any): string { | ||
str = (str || "").replace(/\"\$\{([\w\.\_\:]*)\}\"/gm, (_m, key) => { | ||
let spread = key.split(":"), | ||
type = spread[1] || ""; | ||
key = spread[0]; | ||
let value = data.hasOwnProperty(key) ? ((!data[key] && data[key] !== false) ? "" : data[key]) : ""; | ||
return type == "number" ? (parseFloat(value) || 0).toString() : (type == "boolean" ? Boolean(value).toString() : `"${value}"`) | ||
}); | ||
return Strings.replaceFormat(str, data) | ||
} | ||
public static sanitizeString(str: string): string { | ||
@@ -31,0 +47,0 @@ // u200B is the hex equivalent of unicode 8203 and it will fuck with our encoding function in the ad server |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.20", | ||
"version": "8.0.21", | ||
"license": "MIT", | ||
@@ -23,0 +23,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192594
3428