DEV Community

Yuan-Hsi Lee
Yuan-Hsi Lee

Posted on

Are you a bad link or a good link?

Before the coding

How to check if a URL is valid or not? How to check if many URLs are valid or not? Should we check the syntax? How about the HTTP status?

I started this project by researching something like "URL checker" applications and some open source projects. Observe how they test a URL such as what determines a URL is valid or not.

After the researches, I got some ideas of how I can develop this too. I decided to use C# for this project because I want to get familiar with this language.

The development

The concept of checking URL format and status is not hard to accomplish with a C# console app. However, it was a bit of a challenge of how to make it a "tool" for other users to use. After comparing different methods, I chose Nuget package. It is friendly in different operating systems and also easy to maintain and control the version.

It is also a good practice for me to working with packages.

How to install the tool?

This tool has been packed into a Nuget package. You may install it through the website or Nuget package or any other platform. However, I recommend the simplest way by typing the command on your terminal.

dotnet tool install --global OSD600.GoodLinkOrBadLink --version 1.0.4

How does this tool work?

After Nuget package installation, the user can use this tool by typing the command "goodOrBad".

Alt Text

With no argument passing, the command will return a short introduction of this tool.

By passing --v or --version, the user can see the current version of the package.

Alt Text

By passing the file in the current directory or file with a path, the user will see the system is reading the file. The system will first check if the file exists. Then, it checks if the lines in the file match the format of a URL. If it doesn't, the tool returns "not a URL".

Alt Text

If the URL matches the format, the tool returns the HTTP status code of the URL. For example, the URLs with 200 status code are [GOOD] and the URLs with 410 or 404 are [BAD]. For the others, the tool will just return [Unknown].

Alt Text

However, if the user inputs an invalid argument such as an invalid file name, the tool returns a warning.

Alt Text

Improve it

More features are developing. Feel free to file an issue if you face problems while using this tool. Also, if there is anything you would like to be on this tool, please let me know :-)

The GitHub repo: https://github.com/yuanLeeMidori/OSD600.GoodLinkOrBadLink

Top comments (0)