I'm aware that you can get the query string of a URL like:
var url = require("url");
...
http.createServer((req,res) => console.log(url.parse(req.url).query))
But that's only if the variables are in a query-string format:
example.com/index.html?key=val&key2=val2
etc...
But what if I wanted to get the "variables" in the form of values if the url was in a format:
example.com/key/val/key2/val2
?
I could just split the array for /'s and then map it accordingly:
var pathParts = request.url.split("/").filter(x => x.length > 0).map(x => x.split("%20").join(" "));
but that would fail for a URL like this:
example.com/url/http://google.com
So how can I get each of the values separated by / as a unique array element, even if there are nested /'s ?
example.com/url/http%3A%2F%2Fgoogle.com