abhijeetnishal / URLShortener

URL Shortener Deployed Link 👇🏻
https://urlsrtner.vercel.app
MIT License
38 stars 62 forks source link

middleware added for validating the url #88

Closed RoshanAnsy closed 1 month ago

RoshanAnsy commented 2 months ago

we added the new file middleware that is validates the given url first. If the url is valid then it call next functions for shorten the url.

if the url is not valid then it return to client is that entered url is not valid. Additionally, we have also improved the code formatting

Solves #58

Screenshot 2024-05-16 095217

Screenshot 2024-05-16 094639

vercel[bot] commented 2 months ago

@RoshanAnsy is attempting to deploy a commit to the Abhijeet's projects Team on Vercel.

A member of the Team first needs to authorize it.

abhijeetnishal commented 2 months ago

Hey @RoshanAnsy, we haven't discussed about this issue. Please don't create a PR directly it will waste you work if the issue is not necessary

RoshanAnsy commented 2 months ago

please schedule the meeting for it.

abhijeetnishal commented 2 months ago

We have discussion section on github we can discuss there

abhijeetnishal commented 2 months ago

Hey @RoshanAnsy, have you tested this, is it working i.e. it is validating URL's?

RoshanAnsy commented 2 months ago

Yes it is working.

abhijeetnishal commented 2 months ago

Hey @RoshanAnsy, i just checked it's not working Screenshot 2024-05-21 175348

RoshanAnsy commented 2 months ago

You are checking the request payload, but you should check the response options.

Screenshot 2024-05-22 094958

abhijeetnishal commented 2 months ago

But the URL I have added is invalid it should show invalid right? Leave it request response option for now

abhijeetnishal commented 2 months ago

I tried with this URL https:/github.com/ but it still shortened it.

RoshanAnsy commented 2 months ago

when we hit the request to browsers it automatically correct certain mistakes in URLs. For example, they might interpret http:/github.com as http://github.com by adding the missing slash.

And as the result it gives you corrects url.

abhijeetnishal commented 2 months ago

Ok @RoshanAnsy, I will test it with other URL's and let you know. If it works then I will review the code and merge.

RoshanAnsy commented 1 month ago

All changes have been made as you mentioned.

abhijeetnishal commented 1 month ago

Hey @RoshanAnsy, resolve the conflict as I mentioned in the first comment else it will not merge.

RoshanAnsy commented 1 month ago

I think as you mentioned I did changes in the code base but if some conflict is there it may be due to your code base structure has changed at the major level [ I am working with your old code base may be that's the reason of conflict ].

After all that if you want to that I resolve the conflict please schedule the meeting for it I can fix it. It does not take more time I think 10 minutes is enough for it. I think I don't have permission to resolve the conflict. Look the button of Resolve conflict is not working for me.

Screenshot 2024-05-26 132957

abhijeetnishal commented 1 month ago

Hey @RoshanAnsy, this happens because of other contributers add code.

If you are using vscode:

  1. Pull the latest code using command: git pull origin master
  2. In vs code it will show files with conflict then open that file and then you will get two options accept current and accept incoming. Select accept current if you have changed the code else select incoming.
  3. Once done select confirm merge.
  4. Finally commit the changes, it will fix this issue for sure.
RoshanAnsy commented 1 month ago

Have you have checked my latest commit bz for me no any conflict is visible in my vs code.

RoshanAnsy commented 1 month ago

I resolve the conflict please check it.

abhijeetnishal commented 1 month ago

Hey @RoshanAnsy, there are some issues/suggestion:

  1. isValidURL is not imported in urls routes file that's why its failing to start the server.
  2. Toast notification not added for invalid URL.
  3. Try to use prettier for code formatting to structure code.
  4. Avoid adding success from response, success/failure depends on http status code.

Good luck.

Thanks for contributing.