question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Curriculum test regex does not cover some code formats

See original GitHub issue

Affected page Affected page

Your code

  passport.use(
    new GithubStrategy(
      {
        clientID: process.env.GITHUB_CLIENT_ID,
        clientSecret: process.env.GITHUB_CLIENT_SECRET,
        callbackURL:
          "https://myapplication.myId.repl.co/auth/github/callback",
      },
      (accessToken, refreshToken, profile, cb) => {
        console.log(profile);
      }
    )
  );

The callback url is redacted.

Expected behavior I expected this code to pass the tests. But it did not.

System (please complete the following information):

  • Device: [Laptop]
  • OS: [Ubuntu 20.4]
  • Browser: [Opera]
  • Version: [77]

Additional context The third test GitHub strategy should be setup correctly thus far. didn’t pass. So, I ran FCC on my local computer and checked the tests on the page. The first regex test is as follows:

      assert.match(
        data,
        /passport\.use.*new GitHubStrategy/gi,
        'Passport should use a new GitHubStrategy'
      );

The regex won’t pass if new GitHubStrategy is on a new line because . matches all characters except for the new line. When I replaced . with [\s\S] the tests passed. So I think we should change this test to the following:

      assert.match(
        data,
        /passport\.use[\s\S]*new GitHubStrategy/gi,
        'Passport should use a new GitHubStrategy'
      );

My reasoning is that the correctness of a solution should not depend on formatting. Especially when the formatting is not something very abnormal.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
alirezagheycommented, Jun 25, 2021

Hi @aileenpalafox Are you sure you haven’t a false positive produced by the commented out GithubStrategy? Neither of the regexes can differentiate between commented and uncommented code.

0reactions
aileenpalafoxcommented, Jun 25, 2021

You’re totally right, @alirezaghey! I completely forgot about that, sorry. I deleted the commented code and now the test is not passing. Tomorrow will be trying the fix both of you suggested. Thank you for your response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Regex: A Practical Guide to Regular Expressions ...
A regex is a string of characters that defines a search pattern. The most basic example would be a straight string match, for...
Read more >
Why does this take so long to match? Is it a bug?
First off, I must say that this is not a BUG. What your regex is doing is that it's trying all the possibilities...
Read more >
Why is my regex working intermittently? - DEV Community ‍ ‍
When the RegExp test method is run with global flag (/g), the regex keeps internally the state of the search. Therefore at each...
Read more >
Learn Regular Expressions with this free course
This course follows along with the RegEx curriculum at freeCodeCamp.org. You can check that out for coding challenges and to earn a certificate....
Read more >
Regular expressions should not be vulnerable to Denial of ...
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C# code ... Overflow checking should not be disabled for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found