From 6cb7c2b770181f1ab31c5ac065d4c0c46ac03d77 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 15 Feb 2022 14:48:32 +0000 Subject: [PATCH] Fix for safari, removing all usage of regex lookbehinds. --- packages/client/package.json | 2 -- packages/string-templates/src/index.js | 5 ++--- packages/string-templates/src/utilities.js | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index fdf0125afa..cf12724e18 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -41,8 +41,6 @@ "@spectrum-css/vars": "^3.0.1", "apexcharts": "^3.22.1", "dayjs": "^1.10.5", - "fs-extra": "^8.1.0", - "jsdom": "^16.0.1", "postcss": "^8.2.10", "rollup": "^2.44.0", "rollup-plugin-json": "^4.0.0", diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index 7996bb9f1f..c0b5563f3d 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -3,7 +3,7 @@ const { registerAll, registerMinimum } = require("./helpers/index") const processors = require("./processors") const { atob, btoa } = require("./utilities") const manifest = require("../manifest.json") -const { FIND_HBS_REGEX, FIND_DOUBLE_HBS_REGEX } = require("./utilities") +const { FIND_HBS_REGEX, findDoubleHbsInstances } = require("./utilities") const hbsInstance = handlebars.create() registerAll(hbsInstance) @@ -135,8 +135,7 @@ module.exports.processStringSync = (string, context, opts) => { * @param string the string to have double HBS statements converted to triple. */ module.exports.disableEscaping = string => { - let regexp = new RegExp(FIND_DOUBLE_HBS_REGEX) - const matches = string.match(regexp) + const matches = findDoubleHbsInstances(string) if (matches == null) { return string } diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js index 9704f84ecc..0572350d62 100644 --- a/packages/string-templates/src/utilities.js +++ b/packages/string-templates/src/utilities.js @@ -1,7 +1,25 @@ const ALPHA_NUMERIC_REGEX = /^[A-Za-z0-9]+$/g module.exports.FIND_HBS_REGEX = /{{([^{].*?)}}/g -module.exports.FIND_DOUBLE_HBS_REGEX = /(? { + let copied = string + const doubleRegex = new RegExp(exports.FIND_HBS_REGEX) + const regex = new RegExp(exports.FIND_TRIPLE_HBS_REGEX) + const tripleMatches = copied.match(regex) + // remove triple braces + if (tripleMatches) { + tripleMatches.forEach(match => { + copied = copied.replace(match, "") + }) + } + const doubleMatches = copied.match(doubleRegex) + return doubleMatches ? doubleMatches : [] +} module.exports.isAlphaNumeric = char => { return char.match(ALPHA_NUMERIC_REGEX)