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

273
Vistas
How to find the given image source (url) is in svg format?

I am getting images as URLs from my CMS provider like this

SVG image src URL:

https://example.com/svg.png

Here I am getting images in different formats like png, jpeg, jpg, SVG, etc... In this, I need to find the images only in SVG format.

I planned to create a utility function and going to pass all the image URLs to it. It will return true only if the image is in SVG format else it will return false.

Is there any way I can do this in Javascript (ReactJS)? If any source or plugin is available. Please share that.

Will this function work ?


function isSvgFormatImage(url) {
  return url.split('.').includes('svg')
}

Thanks in advance

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

0

Yes, your function would work, one a little more efficient would be:

/**
 * @param {string} url
 */
function isSVGFormatImage(url) {
  return url.endsWith(".svg");
}

// Some test cases

console.assert(isSVGFormatImage("https://example.com/another.svg") === true);

console.assert(isSVGFormatImage("https://example.com/svg.png") === false);

console.assert(isSVGFormatImage("https://example.com/file.jpg") === false);

  • console.assert docs
about 4 years ago · Juan Pablo Isaza Denunciar

0

If the url ends in ".svg", this function returns true

function isSvgFormat (url){
   return url.endsWith(".svg")
}
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