Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_parseName(fullName) {
let [ type, fullNameWithoutType ] = fullName.split(':');
let name = fullNameWithoutType;
let namespace = get(this, 'namespace');
let root = namespace;
let lastSlashIndex = name.lastIndexOf('/');
let dirname = lastSlashIndex !== -1 ? name.slice(0, lastSlashIndex) : null;
if (type !== 'template' && lastSlashIndex !== -1) {
let parts = name.split('/');
name = parts[parts.length - 1];
let namespaceName = StringUtils.capitalize(parts.slice(0, -1).join('.'));
root = Namespace.byName(namespaceName);
assert(
`You are looking for a ${name} ${type} in the ${namespaceName} namespace, but the namespace could not be found`,
root
);
}
let resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : StringUtils.classify(type);
if (!(name && type)) {
throw new TypeError(`Invalid fullName: \`${fullName}\`, must be of the form \`type:name\` `);
}
return {
fullName,
type,