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

Added Validation for formState.link in advertisementRegister #1482

Closed
wants to merge 3 commits into from
Closed

Conversation

Keshav-0907
Copy link

What kind of change does this PR introduce?
This pull request introduces a isValidLink() function to validate the link entered when creating an advertisement.

Issue Number:

Fixes #1479

Did you add tests for your changes?
No

Snapshots/Videos:

Untitled.mp4

If relevant, did you update the documentation?

No(not required)

Summary

Currently the user is allowed to input random strings or potentially invalid data in the formState.link. So, this PR fixes the issue by first validating if the formState.link is actually a link before creating a new advertisement.

Does this PR introduce a breaking change?

No

Other information

Have you read the contributing guide?
Yes

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

export const isValidLink = (link: string): boolean => {
const pattern = new RegExp(
'^(https?:\\/\\/)?' +
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with '0' and containing many repetitions of '0'.
@Keshav-0907
Copy link
Author

Updated the PR resolving the Inefficient regular expression warning.

Screen.Recording.2024-01-27.at.12.17.32.AM.mov

@Keshav-0907 Keshav-0907 closed this by deleting the head repository Jan 27, 2024
@palisadoes
Copy link
Contributor

We have a policy of unassigning contributors who close PRs without getting validation from our reviewer team. This is because:

  1. We start looking for people to review PRs when you submit them.
  2. We often contact them and link to the PR. If the PR is closed the whole effort is wasted.
  3. The historical thread of reviewer comments is broken when the work is spread across multiple PRs. The quality of our code is affected negatively.

Please be considerate of our volunteers' limited time and our desire to improve our code base.

This policy is stated as a pinned post in all our Talawa repositories. Our YouTube videos explain why this practice is not acceptable to our Community.

@Keshav-0907
Copy link
Author

Apologies for any inconvenience caused. I understand the importance of following the established policy and will ensure that PRs are not closed without validation from the reviewer team moving forward.
Sorry again, and I appreciate your understanding.

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.

2 participants