Skip to content

Commit

Permalink
fix: operator expression with parentheses breaks parser
Browse files Browse the repository at this point in the history
When splitting `(1,2,6,10,23,24)` against `(`, the first item is an empty string.
The fix consists in filtering-out falsy values from the split array.
  • Loading branch information
papillot committed May 4, 2024
1 parent cfcb84f commit a7cb68e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/cif-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ function processSymmetry (cif: CifCategories, structure: Structure, asymIdDict:
let md:{[k: string]: Matrix4} = {}
let oe = operExpressionField.str(i).replace(/['"]\(|['"]/g, '')

// Example: '(1,2,6,10,23,24)' and '(X0)(1-60)' in 6CGV
if (oe.includes(')(') || oe.indexOf('(') > 0) {
const [oe1, oe2] = oe.split('(')
const [oe1, oe2] = oe.split('(').filter(piece => !!piece)

const md1 = getMatrixDict(oe1)
const md2 = getMatrixDict(oe2)
Expand Down

0 comments on commit a7cb68e

Please sign in to comment.