android-components icon indicating copy to clipboard operation
android-components copied to clipboard

Close #12623: Do not match issue ID if preceded by other characters

Open jonalmeida opened this issue 3 years ago • 1 comments

To avoid matching against issues in other repositories, we can reduce our matches to not include values if they are preceded by 1 or more string/number/hypen/underscore values.

Tested using:

  • a JS console:
    const issueRegExp = new RegExp("(?<![A-Za-z\\-\\_]+)#(\\d+)+", "g");
    const numMatches = Array.from(issueRegExp[Symbol.matchAll]("mozilla-mobile/android-components#12345")).length
    const numMatches2 = Array.from(issueRegExp[Symbol.matchAll](" #12345 ")).length
    
    assert(numMatches == 0);
    assert(numMatches2 == 1);
    
  • regex tester: https://regexr.com/6rg2v
    • We get this warning:

      The "negative lookbehind" feature may not be supported in all browsers."

    • From https://caniuse.com/js-regexp-lookbehind. Chrome has support support for this since version 67 which should be support by node16 that we use.

Pull Request checklist

  • [x] Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • [x] Tests: This PR includes thorough tests or an explanation of why it does not
  • [x] Changelog: This PR includes a changelog entry or does not need one
  • [x] Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

GitHub Automation

Fixes #12623

jonalmeida avatar Aug 09 '22 15:08 jonalmeida

Screen Shot 2022-08-09 at 1 03 03 PM

Case and point. 😄

jonalmeida avatar Aug 09 '22 17:08 jonalmeida