Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve regex pattern #59

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

privatenumber
Copy link
Contributor

Problem

  • Not bound at the end of the string, and the ^ start position was in a capture group
  • Unnecessary capture groups and syntax ({0,1} instead of ?) ((\/|:) instead of [\:])
  • .git should be escaped: \.git
  • The ending pattern (.git){0,1}((\/){0,1}) catches .git/, but it should be either .git or /: (\.git|\/)?

Changes

Simplified and improved regular expression syntax by:

  • Start and end bounds at each end of the pattern to match the full string
  • Removed unnecessary capture groups
  • Escaped .
  • Mutually exclusive .git|/

@benjdlambert
Copy link

@IonicaBizau can we get a review on this? 🙏

@IonicaBizau IonicaBizau mentioned this pull request Aug 30, 2022
@IonicaBizau IonicaBizau merged commit 0baab4f into IonicaBizau:master Aug 30, 2022
@IonicaBizau
Copy link
Owner

@IonicaBizau can we get a review on this? 🙏

Sorry for the late reply and review on this. I only got the chance now to merge these PRs. Let me know if you have any questions or suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants