INNER CODE UNIT · TypeScript

segmentDepthBelowRoot

ZaxbyHub/opencode-swarm · src/cli/index.ts:85

function segmentDepthBelowRoot(resolved: string): number {
	const { root } = path.parse(resolved);
	return resolved
		.slice(root.length)
		.split(path.sep)
		.filter((s) => s.length > 0).length;
}

/**
 * Normalize paths for exact containment comparisons. Windows filesystems are
 * case-insensitive, while POSIX filesystems are not; path.normalize() handles
 * separator and dot-segment normalization on both platforms.
 */
function normalizePathForComparison(value: string): string {
	const normalized = path.normalize(path.resolve(value));
	return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…