Skip to content

Commit

Permalink
cleaned up some of the code in reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
JediWattson committed Dec 7, 2022
1 parent cdd60bc commit a895d00
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ class AttachmentCarousel extends React.Component {

// matchAll captured both source url and name of the attachment
if (matches.length === 2) {
const [src, name] = matches;
if ((this.state.sourceURL && src[2].includes(this.state.sourceURL))
|| (!this.state.sourceURL && src[2].includes(this.props.sourceURL))) {
const [sourceURL, name] = _.map(matches, m => m[2]);
if ((this.state.sourceURL && sourceURL.includes(this.state.sourceURL))
|| (!this.state.sourceURL && sourceURL.includes(this.props.sourceURL))) {
page = attachmentsAccumulator.length;
}
const {href} = new URL(src[2]);
attachmentsAccumulator.push({sourceURL: href, file: {name: name[2]}});
attachmentsAccumulator.push({sourceURL, file: {name}});
}
}
return attachmentsAccumulator;
Expand Down

0 comments on commit a895d00

Please sign in to comment.