Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the URL's hash available on the server with Node.js?

Tags:

node.js

Today, I fell upon this link : Node API's doc for 'url'.

I saw that the hash part is included in the documentation. But isn't this part not available on the server? That's what I always thought.

Any explanation? What did I get wrong?

like image 787
Florian Margaine Avatar asked Jan 25 '12 15:01

Florian Margaine


People also ask

Does NodeJS runs on server?

To summarize, Node. js is a cross-platform JavaScript runtime environment for servers and applications. It is built on a single-threaded, non-blocking event loop, the Google Chrome V8 JavaScript engine, and a low-level I/O API.

What is the use of the url library in node js?

js URL() Method. The 'url' module provides utilities for URL resolution and parsing. The getters and setters implement the properties of URL objects on the class prototype, and the URL class is available on the global object.

What kind of server does node js run on?

Node. js is a Javascript run-time environment built on Chrome's V8 Javascript engine. It comes with a http module that provides a set of functions and classes for building a HTTP server. For this basic HTTP server, we will also be using file system, path and url, all of which are native Node.


1 Answers

No, there will not be a hash in the URL sent from the client to the server as part of the HTTP request.

But that's not the only case where Node would need to manipulate URLs. You could well be writing server-side code to generate a URL that will be inserted into the HTML sent back to the client (e.g., you might have a list of hyperlinks, and be generating the URLs for those hyperlinks).

For that reason, it makes sense for Node's URL API to be complete, even if one part of the URL will be missing in one common use case.

like image 103
Joe White Avatar answered Oct 07 '22 00:10

Joe White