Merge pull request #933 from mikepenz/feature/929
Differentiate between no match vs equal content for transformers
This commit is contained in:
+2
-1
@@ -1730,7 +1730,8 @@ function replacePlaceholders(template, placeholderMap /* placeholderKey and orig
|
|||||||
if (transformer === null || transformer === void 0 ? void 0 : transformer.pattern) {
|
if (transformer === null || transformer === void 0 ? void 0 : transformer.pattern) {
|
||||||
const extractedValue = value.replace(transformer.pattern, transformer.target);
|
const extractedValue = value.replace(transformer.pattern, transformer.target);
|
||||||
// note: `.replace` will return the full string again if there was no match
|
// note: `.replace` will return the full string again if there was no match
|
||||||
if (extractedValue && extractedValue !== value) {
|
if (extractedValue &&
|
||||||
|
(extractedValue !== value || (extractedValue === value && value.match(transformer.pattern)))) {
|
||||||
if (placeholderPrMap) {
|
if (placeholderPrMap) {
|
||||||
(0, utils_1.createOrSet)(placeholderPrMap, placeholder.name, extractedValue);
|
(0, utils_1.createOrSet)(placeholderPrMap, placeholder.name, extractedValue);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+4
-1
@@ -337,7 +337,10 @@ function replacePlaceholders(
|
|||||||
if (transformer?.pattern) {
|
if (transformer?.pattern) {
|
||||||
const extractedValue = value.replace(transformer.pattern, transformer.target)
|
const extractedValue = value.replace(transformer.pattern, transformer.target)
|
||||||
// note: `.replace` will return the full string again if there was no match
|
// note: `.replace` will return the full string again if there was no match
|
||||||
if (extractedValue && extractedValue !== value) {
|
if (
|
||||||
|
extractedValue &&
|
||||||
|
(extractedValue !== value || (extractedValue === value && value.match(transformer.pattern)))
|
||||||
|
) {
|
||||||
if (placeholderPrMap) {
|
if (placeholderPrMap) {
|
||||||
createOrSet(placeholderPrMap, placeholder.name, extractedValue)
|
createOrSet(placeholderPrMap, placeholder.name, extractedValue)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user