Skip to content

Conversation

chrvadala
Copy link
Owner

Scope

This PR refactors fromString(matrix) function with the following benefits:

⚠️ breaking changes

Previous implementation where not fully validating number, providing in some case Number.NaN as output. This new version strictly validate number and may break some part of your code that were silently failing.

This table shows some examples:

parsed string Behaviour versions <=2.17 Behaviour now
matrix(ee,ee,ee,ee,ee,ee) { a: NaN, b: NaN, c: NaN, d: NaN, e: NaN, f: NaN } Error("'matrix(ee,ee,ee,ee,ee,ee)' is not a matrix")
matrix(1px,2px,3px,4px,5px,6px) Error("'matrix(1px,2px,3px,4px,5px,6px)' is not a matrix") { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }

🙅 backward compatibility

In a case that you want still to use the previous implementation, you can replace fromString(matrix) with fromStringLegacy(matrix). At the same time, open an issue in order to show your use case, because future implementations will remove the legacy method.

@chrvadala chrvadala self-assigned this Feb 8, 2025
@@ -14,6 +14,46 @@
* {a: 1, b: 2, c: 3, d: 4, c: 5, e: 6}
*/
export function fromString (string) {
const parseFloatOrThrow = number => {

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
library input
may run slow on strings starting with 'matrix(+,' and with many repetitions of '+,+'.
This
regular expression
that depends on
library input
may run slow on strings starting with 'matrix(+,+,' and with many repetitions of '+,+'.
This
regular expression
that depends on
library input
may run slow on strings starting with 'matrix(+,+,+,' and with many repetitions of '+,+'.
This
regular expression
that depends on
library input
may run slow on strings starting with 'matrix(+,+,+,+,' and with many repetitions of '+,+'.
This
regular expression
that depends on
library input
may run slow on strings starting with 'matrix(+,+,+,+,+,' and with many repetitions of '+,+'.
@coveralls
Copy link

coveralls commented Feb 8, 2025

Coverage Status

coverage: 100.0%. remained the same
when pulling 85a094e on fromStringV2
into 31aba56 on main.

@chrvadala chrvadala merged commit 1179dd7 into main Feb 10, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants