`var express = require(‘express’);
var app = express();
app.get(’/new/:url’, function(req, res){
console.log(req.params.url);
})
app.listen(‘5000’, function(){
console.log(‘Server is on…’);
});
`
When I make a request to http://localhost:5000/new/test
It’s fine, it’s logging “test”
But when I http://localhost:5000/new/http://www.baidu.com
It gives me nothing…
I search this forum and realise I have to put a “*” at the end of route like this…
app.get('/new/:url*', function(req, res){ console.log(req.originalUrl); })
Now when I make a request to http://localhost:5000/new/http://www.baidu.com it will log out new/http://www.baidu.com just fine. but I do not understand why putting an * will make it work. can anyone further explain this?
thanks
Stanley