Skip to content

Odd issue with re2 after resetting yarn.lock file #94

Closed
@niftylettuce

Description

@niftylettuce

This seems like re2 related, but I thought we should major bump on breaking changes in re2 here. I guess not though, and we have to be extra safe.

Here's a code example which shows the breaking change:

str.replace(URL_REGEX, (match, ...args) => { // <-- breaking change here, need to do `(match, offset, string)` instead
  const offset = args[12]; // <--- breaking change here
  const string = args[13]; // <--- breaking change here
  const nextChar = string.slice( // <--- throws error cannot read "slice" of undefined
    offset + match.length,
    offset + match.length + 1
  );
  // NOTE: that matches such as foo.iS will still match as foo.is
  // so we may want to have case-sensitivity option for url-regex
  // in the future, or do that case-sensitivity matching on the tld here
  // (Gmail for example only matches FOO.COM or foo.com)
  // (but note it breaks foo.itýbeep.com into foo.it and ýbeep.com)
  // (note Gmail matches "test.it123.com.foobar_123.com" incorrectly)
  if (new RE2(/^\w$/).test(nextChar)) return '';
  return match;
});

You can reproduce this by:

git clone https://github.com/spamscanner/spamscanner.git
cd spamscanner
npm install
npm test

You'll see the same error here.

If you use "resolutions" field to lock it, then the error goes away.

Previous builds were running fine on v1.15.4 in the past, but if I rebuild it will error. See https://travis-ci.com/spamscanner/spamscanner.

Metadata

Metadata

Assignees

Labels

bugA reported bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions