Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the behavior of Hash(#) in query string

I am sending the below url with query string. In the query string one parameter "approverCmt" has value with hash(#).

    "/abc/efd/xyz.jas?approverCmt=Transaction Log #459505&batchNm=XS_10APR2015_082224&mfrNm=Timberland"

In server side when I tried to retrieve it from the request I get

    approverCmt = Transaction Log  -----> "#459505" is missing
    batchNm = null
    mfrNm = null

And If I remove hash(#) from query string or If I replace # with %23 every thing works fine

I don't understand why I am getting null for one parameter if another parameter contains a hash(#) symbol.

Appreciate if any one can explain.

like image 799
Shekhar Khairnar Avatar asked Apr 24 '15 07:04

Shekhar Khairnar


People also ask

What characterizes a hash?

A Hash is a dictionary-like collection of unique keys and their values. Also called associative arrays, they are similar to Arrays, but where an Array uses integers as its index, a Hash allows you to use any object type. Hashes enumerate their values in the order that the corresponding keys were inserted.

Whats the purpose of a hash?

Hashing is a cryptographic process that can be used to validate the authenticity and integrity of various types of input. It is widely used in authentication systems to avoid storing plaintext passwords in databases, but is also used to validate files, documents and other types of data.

What are the characteristics of a good hash function?

Characteristics of a Good Hash Function. There are four main characteristics of a good hash function: 1) The hash value is fully determined by the data being hashed. 2) The hash function uses all the input data. 3) The hash function "uniformly" distributes the data across the entire set of possible hash values.

What is an example of hash?

An Example of a Hash Hashing the word “hello” will produce an output that is the same length as the hash for “I am going to the store.” The function used to generate the hash is deterministic, meaning that it will produce the same result each time the same input is used.


1 Answers

This is known as the "fragment identifier".

As mentioned in wikipedia:

The fragment identifier introduced by a hash mark # is the optional last part of a URL for a document. It is typically used to identify a portion of that document.

The part after the # is info for the client. It is not sent to the server. Put everything only the browser needs here.

You can use the encodeURIComponent() function in JavaScript to encode special characters in a URL, so that # characters are converted to other characters that way you can be sure your whole URL will be sent to the server.

like image 149
Prashant Avatar answered Nov 05 '22 16:11

Prashant