For the last couple of days I've noticed a problem with some links not going to the proper locations. To most maybe this would just look like a 404 page popping up but if you looked closer at the link you could tell that it was actually looking in the wrong place. At the time I didn't really know what was going on just that something was fucked.

Can you spot the difference between the picture above and this one?

Aside from my cursor being on a different line 🤣 

What we are looking at specifically here is the path: field that is required for each link to tell it where it should send the user when clicked. You can see the first path: we are dealing with is the brandImagePath: '/' on line 13. That is given the value / which means home. It doesn't mean home in the sense of a web page home though in this instance it functions as such, but home in the sense of a folder. Think of a website as one big folder with many files and folders inside of it. If you're at the location website.com/ you're at the home folder. If you're now at website.com/images/, you're no longer at the home folder but inside a folder called images which is inside the home folder. If you're at website.com/images/books, you're in a folder called books inside a folder called images inside the home folder... get it? Whenever you are browsing a website you're just browsing someone elses computer and computer is just a bunch of folders and files. The only reason they call it a server is because it's a computer build for serving things unlike a laptop that is built for sitting in your lap. But regardless at the end of the day they're all just computers. The /  in this context above just means go to the home folder and look for the index.html file. With Unix systems a single / means the root directory of your computer. In this instance it's the "root directory" of our website.

The root directory of a Unix computer is the main folder that houses the entire operating system of your computer, everything and anything. Hence why some goofs like to tell noobs to run rm -rf / which is saying remove recursively(this folder and everything inside of it) and force(don't ask to make sure I'm sure I want to do this) your computers root directory. Which will cripple and quickly ruin your computer permanently. Don't do that.

Different Flavors

Any who, this forward slash comes in some different flavors. You can see a ~/ which is saying your /home folder on a Unix computer as oppose to your computers root directory. On my unix laptop my home directory is called /rick because the username on that computer is rick. So in other words saying ~/ is like saying /rick.

You can also see it in the form of ./ which is our culprit in the image at the top. What this is saying is not go to my websites root directory. It is saying go to the directory that I am already in. This is because in Unix . means here and / means folder so think of it as this folder I'm currently in whatever folder it may be. To give you even more of a headache, .. means the folder above you, or the folder, that the folder your in, is in.

Without the ./ the computer interprets it as a command and not a shell script. This isn't the best example because with programming magic you can get the script to run without using the ./ but still it shows how ./ signifies do something in this folder not somewhere else.

See the ~/ meaning that the folder /periods-in-paths is in the /rick folder, my home directory. If there was no ~ then it would mean the folder was in the root directory.

The Problem Becomes Obvious

After getting the new tags added to the home page today I was going through the live site on my iPad and cell phone looking for new issues that might have arisen with the latest updates. It became obvious that when on certain pages, and clicking the navigation links it was going to the wrong place. The wrong place it was navigating too gave it away.

If you were on the page narco.news/tag/film-and-television and clicked the link in the navigation to go to the Tamaulipas map page it would send you to narco.news/tag/film-and-television/tamap when it should have sent you to narco.news/tamap. This was happening precisely because the path: value had a period at the beginning. Meaning that instead of going back / home and then going to tamap it was going to it from diectory it was in which was film-and-television. Hence the /tag/film-and-television/tamap non sense that was happening.

Dropping the period solved it!

https://github.com/narco-news/front-end/commit/92ce0344518acf59374f8602f7b931f5b1beb803

One might ask... so who was the idiot who put that period there in the first place?! Me 🤪

I remember messing around with it way back when I was working on the navigation and can't remember particularly why I chose to add it at the moment. If you never leave the home page folder, you will not notice anything is wrong. It was only when it jumped into the tags folder that things started to become obviously funky. Thankfully this turned out to be some dumb shit like that and not something required more finagling.