message.url
Only valid for request obtained from http.Server
.
Request URL string. This contains only the URL that is present in the actual HTTP request. If the request is:
GET /status?name=ryan HTTP/1.1\r\n Accept: text/plain\r\n \r\n
Then request.url
will be:
'/status?name=ryan'
If you would like to parse the URL into its parts, you can use require('url').parse(request.url)
. Example:
$ node > require('url').parse('/status?name=ryan') { href: '/status?name=ryan', search: '?name=ryan', query: 'name=ryan', pathname: '/status' }
If you would like to extract the params from the query string, you can use the require('querystring').parse
function, or pass true
as the second argument to require('url').parse
. Example:
$ node > require('url').parse('/status?name=ryan', true) { href: '/status?name=ryan', search: '?name=ryan', query: {name: 'ryan'}, pathname: '/status' }
Please login to continue.