This is what I want to achieve.
Suppose I have the html file with the following tag in it
<script src="https://beta.foo.com/test.js"></script>
I need a function which I can can call from inside the test.js file, to get the URL 'https://beta.foo.com/test.js'
If the html file which loaded the js file used the following tag to pull the js file
<script src="https://production.foo.com/test.js"></script>
Then the function should give me 'https://production.foo.com/test.js', if called from inside test.js
The reason I need this, is because of the effort I have to put in, while deploying my code to production. The test.js file uses is an API, with quite a few AJAX calls, which have to switch from beta to prodction as per which server they are called from.
I have already made it such that I can change this from a single variable, but then I would like it if I don't have to touch that variable during deployment of my code.