Arnas A.
Arnas A.

Reputation: 61

Decode hex string with percentage symbol (%HH)

I need to change string from this:

Fast-9%20|%20Speed%20(Something-Cool)

To this:

Fast-9 | Speed (Something-Cool)

How can I do it in NodeJS?

Upvotes: 1

Views: 593

Answers (3)

slomek
slomek

Reputation: 5126

var decoded = decodeURIComponent("Fast-9%20|%20Speed%20(Something-Cool)");

Upvotes: 0

Sarjan Desai
Sarjan Desai

Reputation: 3733

Try this:

var str = 'Fast-9%20|%20Speed%20(Something-Cool)';
str = str.replace(/%20/g, " ");
alert(str);

Upvotes: 0

Rayon
Rayon

Reputation: 36609

Refer decodeURIComponent

The decodeURIComponent() method decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.

var str = 'Fast-9%20|%20Speed%20(Something-Cool)';
alert(decodeURIComponent(str));

Upvotes: 4

Related Questions