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

211
Vistas
How can I delete one part of the string without deleting the same set of characters in another place?

I'm trying to clean up a string (URL). I need that every time it contains ipfs://ipfs/ to replace it by a single ipfs/. The full string is ipfs://ipfs/QmR6xjBCn but it should be ipfs://QmR6xjBCn In some cases I get string that are already clean, in other cases I dont'.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I've used include to detect if the string contained ipfs://ipfs and then replaced it for what I needed: ipfs://

if (fixedURL.includes('ipfs://ipfs')) {
  fixedURL2 = fixedURL.replace('ipfs://ipfs','ipfs://')

  obj.imageUrl = fixedURL2;
} else {

  obj.imageUrl = fixedURL;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Use the replace() function. If the text is not in the string then it won't replace anything. So it only works when the double ipfs is there.

let str;
// example one
str = "ipfs://ipfs/QmR6xjBCn";
str = str.replace("ipfs://ipfs/","ipfs://");
console.log(str);

// example two, same code different url
str = "ipfs://SomethingRandom";
str = str.replace("ipfs://ipfs/","ipfs://");
console.log(str);

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