DEV Community

Avelyn Hyunjeong Choi
Avelyn Hyunjeong Choi

Posted on

Hacktoberfest #04

Issue | Pull Request

Issue
The issue pertains to auto-correcting the GitHub source URL. Currently, if a user inputs an extended GitHub URL (https://github.com/avelynhc/til_tracker/tree/main) instead of the repository URL (https://github.com/avelynhc/til_tracker), it results in an invalid GitHub repository error. The extended GitHub URL should be trimmed to the form https://github.com/<user|org>/<repo-name>.

Set-up

  1. Run docker compose up
  2. Open localhost:5173 in browser
  3. Utilize the Swiftwave staging environment without the need to install the server by using the provided credentials in the README.md file.

Changes
Before
before image

After
after image

Changes in code

const pattern = /^(https:\/\/(?:github\.com|gitlab\.com|bitbucket\.org)\/[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+)\/tree\/(?:main|master)$/;
const new_repo_url = repository_url.replace(pattern, '$1');
...
Enter fullscreen mode Exit fullscreen mode

Interactions with the project maintainers
After I pushed my PR, I received a comment suggesting that I use useRef instead of useState. I asked for advice on how to implement this, and in response, he sent me a blog post related to the issue I was dealing with. The blog post helped me resolve the problem, and I was able to make the change as per the maintainer's request.

Learning experience
At first, I felt overwhelmed by the idea of having to go through every line of code in this project just to fix a bug. However, I soon realized that this isn't always necessary, especially for small bugs in specific areas. I only needed to pinpoint the exact location of the bug and make the necessary changes in those specific areas. To be honest, besides the page I made changes to, I have no idea what else is going on in this project.

In addition, I realized that I didn't have to struggle alone. Once I reached out to the maintainer for help, he was more than happy to assist me. It was reassuring to know that I wasn't the only one dealing with the issue. Perhaps this is one of the great things about working on an open-source project.

Top comments (0)