From 86583104d9601855c01f63bdfe806de6b112b411 Mon Sep 17 00:00:00 2001 From: Nick Yonge Date: Sat, 10 Jun 2023 01:10:58 -0700 Subject: [PATCH] Array parsing accommodates spaces as well as commas You can define transforms as `translate(100,200,300)' or 'translate(100 200 300)'. Both can be used validly when reading them, but transform-parser only accepts the former. This uses regex to accept the latter too. --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 1b8c1f7..c3eafed 100644 --- a/index.ts +++ b/index.ts @@ -34,7 +34,7 @@ const parse = (transformString: string): TransformObject => { return transforms.reduce((acc, transform: string) => { if (!transform) return acc; const [name, transformValue] = transform.split('('); - const valueArray = transformValue.split(','); + const valueArray = transformValue.split(/\s|,/); const values = valueArray.map((val) => { return parsePixelValues(val.endsWith(')') ? val.replace(')', '') : val.trim()); });