Skip to content

Instantly share code, notes, and snippets.

@SaraVieira
Last active October 24, 2018 13:48
Show Gist options
  • Save SaraVieira/a820bc05e629d86ef194dadc21313a8d to your computer and use it in GitHub Desktop.
Save SaraVieira/a820bc05e629d86ef194dadc21313a8d to your computer and use it in GitHub Desktop.
const path = require("path");
const imageExtensions = require("image-extensions");
const isImage = value => {
if (typeof value !== "string") return null;
const extension = path.extname(value).slice(1);
if (imageExtensions.includes(extension)) return value;
return null
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment