| 72 | * Validate a project slug (e.g. "my-project" or "group/my-project"). |
| 73 | */ |
| 74 | export function isValidProjectPath(project: string): boolean { |
| 75 | if (!project) return false; |
| 76 | const normalized = path.posix.normalize(project); |
| 77 | if (normalized.startsWith("..") || path.isAbsolute(normalized)) return false; |
| 78 | if (normalized.includes("\0")) return false; |
| 79 | const segments = normalized.split("/").filter(Boolean); |
| 80 | if (!segments.length) return false; |
| 81 | return segments.every((s) => /^[a-z0-9][a-z0-9-]*$/.test(s)); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * mkdir -p helper. |