Miser
Miser

Reputation: 109

How do I get the full url

How do I get the full url , such as http://user:[email protected]:8080/p/a/t/h?query=string#hash . Useing request.url can get /p/a/t/h?query=string ,but I hope to get full including #hash. What should I do?

var http = require('http');
var url = require('url');
http.createServer(function (request, response) {
   response.writeHead(200, {'Content-Type': 'text/plain'});
   response.end(request.url + '\n');
}).listen(8124);

Upvotes: 3

Views: 2199

Answers (2)

Vikdor
Vikdor

Reputation: 24124

The content after "#" is a bookmark on the client side and is not part of the URL sent to the server. You may want to read about "back button" problem to understand what it means. Something related to this on SO: Detecting Back Button/Hash Change in URL.

Upvotes: 1

Brad
Brad

Reputation: 163272

The hash is not sent to the server. You cannot get it server-side. (At least, not without some code running client-side sending it in another request over AJAX.)

Upvotes: 2

Related Questions