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

114
Vistas
Append string using regex at the end of URL values inside the nested object on Node.js

Sample object (the below object is a very large nested object):

const obj = { a: 1, url: "https://someurl.com", b: { c: 1, d: { otherUrl: "https://someotherurl.com"}};

I want to append some query parameter at the end of each URL, like ?d=1234.

I tried to do it, but the URLs are changed:

const convertedObj = JSON.stringify(obj);
let bufferObj;
const fullRegex = /url":"([^"]*)/g;
const fullMatch = convertedObj.match(fullRegex);

if(fullMatch) {
  fullMatch.forEach((str, i) => {
    bufferObj = convertedObj.replace(/(url|Url)":"([^"]*)/g, `${str}?d=1234`);
  });
}

Is there a solution for this in Node.js using regex?

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

0

let convertedObj = JSON.stringify(obj);
const fullRegex = /(url|Url)":"([^"]*)/g;
const fullMatch = convertedObj.match(fullRegex);

if(fullMatch) {
  fullMatch.forEach((str, i) => {
    convertedObj = convertedObj.replace(str, `${str}?d=1234`);
  });
}
console.log(convertedObj);
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