Skip to content

Commit 1986499

Browse files
committed
fix Potential Undefined Access. Add a null check before accessing properties of the to variable
1 parent a78944e commit 1986499

File tree

1 file changed

+2
-2
lines changed
  • plugins/filters/extractDependabotVersionBump

1 file changed

+2
-2
lines changed

plugins/filters/extractDependabotVersionBump/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111

1212
module.exports = (desc) => {
13-
if (desc && desc !== '""' && desc !== "''" ) {
13+
if (desc && desc !== '""' && desc !== "''" ) {
1414
// Match both "Bumps" and "Updates" patterns with version numbers
1515
// The regex captures version numbers that follow "from" and "to" keywords
1616
const regex = /(Bumps|Updates).*?from ([\d\.]+[A-Za-zαß]*) to ([\d\.]+[A-Za-zαß]*)/;
1717
const matches = regex.exec(desc);
1818
if (matches && matches.length == 4) {
1919
var [_, action, from, to] = matches;
2020
// Remove trailing dot on the "to" version if present
21-
if (to && to[to.length - 1] === ".") {
21+
if (to && to.length > 0 && to[to.length - 1] === ".") {
2222
to = to.slice(0, -1);
2323
}
2424
// Return [to, from] format to be compatible with compareSemver

0 commit comments

Comments
 (0)