Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
JavaScript - Encode characters and URI malformed error

I recently have a bug, when I try to send into my node server a query search of the following:
!@#$%^&*()_+
I get an error on my Chrome:

{status: 500, message: "URI malformed"}
message: "URI malformed"
status: 500

After reading:
When are you supposed to use escape instead of encodeURI / encodeURIComponent?
Javascript decodeURI(Component) malformed uri exception
any way of making encodeURIComponent in javascript ignore certain characters?
Percent encoding javascript
Pass a percent (%) sign in a url and get exact value of it using php
Javascript decodeURI(Component) malformed uri exception

My code still won't work for: !@#$%^&*()_+ when I wrap my string with encodeURIComponent and in the server do decodeURIComponent.
It also does not work with encodeURL.
If I do manually replace I get %2525 and it's not good.
Any idea how to solve it?
Thanks.

My code:

const endpoint = `${endpoint}&text=${encodeURIComponent(query)}`;
await fetch(endpoint);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Eventually there was a bug on my server side. I tried to decode the '%' sign. Solved it by the following:

On the client:

const endpoint = `${endpoint}&text=${encodeURIComponent(query)}`;
await fetch(endpoint);

On the server:

decodeURIComponent(encodeURIComponent(query.text))
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda