Uncaught ReferenceError: url is not defined

I’m attempting to parse the URL into a variable, but I receive the following error:

Uncaught ReferenceError: url is not defined

My goal is to allow the use of extensions to determine the content displayed on a page.

i.e. www.example.com?testpage1

Based on the above example, the value “?testpage1” would be compared to an array to determine which data will be displayed.

I’ve used the following code to parse this information unsuccessfully.

var newURL = window.location.pathname;

I thought the extension would appear in the pathname value, but through the use of console.log I have found that is not working as expected.

Any suggestions on how to parse the data I need?

I found the answer I was looking for.

var url = document.location.href;
	newURL = url.substring(url.lastIndexOf("/") + 1, url.length);