MCPcopy Index your code
hub / github.com/Fission-AI/OpenSpec / extractNameFromPath

Method extractNameFromPath

src/core/validation/validator.ts:372–389  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

370 }
371
372 private extractNameFromPath(filePath: string): string {
373 const normalizedPath = FileSystemUtils.toPosixPath(filePath);
374 const parts = normalizedPath.split('/');
375
376 // Look for the directory name after 'specs' or 'changes'
377 for (let i = parts.length - 1; i >= 0; i--) {
378 if (parts[i] === 'specs' || parts[i] === 'changes') {
379 if (i < parts.length - 1) {
380 return parts[i + 1];
381 }
382 }
383 }
384
385 // Fallback to filename without extension if not in expected structure
386 const fileName = parts[parts.length - 1] ?? '';
387 const dotIndex = fileName.lastIndexOf('.');
388 return dotIndex > 0 ? fileName.slice(0, dotIndex) : fileName;
389 }
390
391 private createReport(issues: ValidationIssue[]): ValidationReport {
392 const errors = issues.filter(i => i.level === 'ERROR').length;

Callers 2

validateSpecMethod · 0.95
validateChangeMethod · 0.95

Calls 1

toPosixPathMethod · 0.80

Tested by

no test coverage detected