As per various docs and blogs, as well as this question and others, I'm aware that one can validate route parameters by using regular expressions. This, however, has had me searching for roughly an hour and a half:
app.get('/api/:url(/^http:\/\/(.+?)\.(.+?)$/)', (req, res) => {
// do stuff with req.params.url
});
Where every time I run the server locally and enter localhost://8000/api/http://www.google.com
, the response is Cannot GET /new/http://www.google.com
I know the Regular Expression does what I want it to do, because :
/^http:\/\/(.+?)\.(.+?)$/.test('http://www.google.com');
... returns true.
I've also tried changing the route string to look like...
'/api/:url(^http:\/\/(.+?)\.(.+?)$)'
'/api/:url(http:\/\/(.+?)\.(.+?))'
'/api/:url/^http:\/\/(.+?)\.(.+?)$/'
And several other formats that look anything remotely like the examples given in Stack Overflow threads and blogs (the Express docs have absolutely no examples of a Regular Expression used outside of the first route param). Perhaps there are some formatting constraints that I'm unaware of, or a limitation to RegExp support in Express? It'd be great if the docs said anything at all.
I appreciate any help I can get here.