Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function matchingComponent(rawComponentName, path) {
if (typeof path !== "string") {
return false;
}
if (typeof rawComponentName !== "string") {
return false;
}
if (!isValidComponentExtension(path)) {
return false;
}
let componentName = dasherizePath(rawComponentName);
let normalizedPath = normalizePath(path);
let possibleExtensions = [
".ts",
".js",
".hbs",
"/component.ts",
"/index.js",
"/index.ts",
"/index.hbs",
"/component.js",
"/template.hbs"
];
let possibleEndings = possibleExtensions.map(ext => componentName + ext);
const classicIgnores = ['app/controllers/','app/helpers/','app/services/','app/utils/', 'app/adapters/', 'app/models/', 'app/routes/'];
let result = possibleEndings.filter((name) => {
return normalizedPath.endsWith('/' + name) && classicIgnores.filter((substr) => normalizedPath.includes(substr)).length === 0;