One of my parameters in the routing is actually an url.
router.get('/api/sitemap/:url', function(req, res)
{
var url = req.params.url;
...
}
How do I allow this to go through when the :url is actually a link like "http://domain.com/file.xml".
I get a 404 error which I understand as it is not linking properly and cannot process as it errors.
Thanks in advance.
Your router returns 404 because it can't recognize the path. You should either encode the url param as suggested in the comments, or slice it further, as:
.get('/api/site/:domain/: file', cb)
The trouble there is that if you also pass the protocol, you have to match even that.
Don't have a console to try now, but I think you might be able to pass a wildcard:
'/api/sitemap/*'
You would have to parse out the url on your own then, but it's simple:
var url = req.url.substr(14);
(Not sure if it's 13 or14 on the index there, counting on hands since I'm on my mobile :-)).