Currently it takes the second to last item in the array from the URL. However we want to do a check for the last item in the array to be "index.html" and if so, grab the third to last item instead.
In the event that our server serves the same file for "index.html" and "inDEX.htML" we can also use: .toLowerCase().
Not sure if there's a drawback, but this seems quite concise:
Both will return undefined if the array is empty.
- Use Array.pop:
A shorter version of what @chaiguy posted:
Two options are:
The former is faster, but the latter looks nicer