Lab 7 : Final Pull Request

This week I had to do the final pull request for Hacktoberfest. I hunted down some issues but then I remembered of a repository in which I was not able to do a PR for an issue. The repository was a project on creating an extension for chrome that could parse a url and grab parameters the url is using. You can find the repository here. The issue was resolved by someone else though, so I stumbled upon another issue in the same repository. The issue was adding a new feature for exporting the parameters of a url as JSON file. You can view the issue here.  

The beginnings:

I began working with the issuse as I did in my Release 0.1 Post. I forked the repository and cloned it to my computer.

It seemed to be an easy project to work with. I went to the file popup.js where the logic of the buttons resides. I saw that the Export button invokes the function create_csv which exports the file to CSV.  The issue does not talk about any UI changes to be done to use export as json option so  I just stick to creating a new function to create and return a JSON file. In the new function was just going to use a variable that can store the result of JSON.Stringify(parameters). I wrote the code and tested it. The code looked like this:

The file being downloaded was a JSON file but it was empty. I checked to make sure what was happening and a simple console.log made the issue appear.The values in parameter_array were not being converted correctly using JSON stringify. I have used JSON stringify before and wondered what was the issue. I looked at the output of console.log again and realized that the parameter_array was not a standard array with numeric index values but instead had string index values. The parameters_array were not just a normal array but were an associative array. In other words the index of this array is a string and the value is a string as well. You can read here about this kind of array objects.

The fix

To fix this, I googled more to learn how to deal with using JSON stringify with an associative array and found some tips and workaround on doing it. I create a new empty array which was then populated using values coming from a for loop on the parameters_array associative array.

Then I used JSON.stringify on the new array and returned the JSON file. It worked. The code looked like this:

I create a new branch issue-13 and pushed the code to it. You can view the branch with the new code here.

I submitted a pull request and now waiting for a review and to get it merged.

Happy Coding !


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

Create your website at
Get started
%d bloggers like this: