Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

357
Views
Is Node decodeURIComponent idempotent? If not, is there an idempotent alternative?

Is Node decodeURIComponent idempotent?

Does...

decodeURIComponent(x) === decodeURIComponent(decodeURIComponent(x))

for any and all x?

If not, is there an alternative that is idempotent? Was trying to think through if this was possible myself.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

No

> encodeURIComponent('%')
'%25'
> encodeURIComponent(encodeURIComponent('%'))
'%2525'

> decodeURIComponent('%2525')
'%25'
> decodeURIComponent(decodeURIComponent('%2525'))
'%'

> decodeURIComponent('%2525') === decodeURIComponent(decodeURIComponent('%2525'))
false
about 4 years ago · Juan Pablo Isaza Report

0

No. If the string decodes to a new sequence which itself can be interpreted as an encoded URI component, then it can be decoded again to a different string:

const x = '%2521';
console.log(decodeURIComponent(x), decodeURIComponent(decodeURIComponent(x)));

%2521 → %21 → !

Any given string is either encoded in a specific format or is plain text. You cannot guess what it is supposed to be. %21 could either be the plaintext string "%21", or a URL-encoded string representing "!". You need to know which it's supposed to be and interpreted it accordingly. That generally goes for any and all text encoding formats.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!