How can I get the value after the very first slash "if a slash is there" from a giving URL?
If the URL is domain.com I want to return empty string.
if the URL is domain.com/index.html I want to also return an empty sting
If the URL is domain.com/dev or domain.com/dev/new/blah.html I want to return 'dev'
Note: I don't know what will be the values after the first slash
Here is what I have done
var icwsSiteBaseURL = document.location.pathname.split("/").slice(1, 2).toString();
My code work for the first and third example but will not return an empty string for the second example. It will return index.html
index.html? So, after the line you have, write a simpleifstatement to check for that and set the variable to''if it is indeedindex.html.domain.com/my.filewheremy.fileis the name of a file, like yourindex.htmlexample. What then separates the two cases? Is it only for.html? what about.css,.js, or files likehello.world? And then, how do you know it's not a URL with a separator containing a dot in file name, e.g. `domain.com/index.html/we.like.dots/helloindex.htmlindex.htmlcan beblah.phpor anything else