I'm using javascript to retrieve a url parameter from the browser and pass it to a server running sockets.io. It's working exactly as intended, but I would like to grab the parameter without requiring the question mark or equal sign.
Instead of /?var=
I would like it to be: /var-
or /var_
, etc.
Is there a good way to accomplish this without server-side URL rewriting?
Current code:
var urlParam = location.search.split("var=")[1]; // get the url parameter http://localhost/?var=[some url parameter value]
if (urlParam == null) {
socket.emit('newRoom');
} else {
socket.emit('urlParam', urlParam);
}
Thanks!