Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const determineMediaTypeBasedOnFileName = (resource: string, rawContent: Buffer): string | null => {
const fileName = getFileName(resource);
if (!fileName) {
return null;
}
const configFileNameRegex = /^\.[a-z0-9]+rc$/i;
if (!configFileNameRegex.test(fileName)) {
return null;
}
try {
// Determine if this is a json file.
JSON.parse(rawContent.toString());
} catch (err) {
return 'text/plain';