(input: string)
| 1 | import type { ParsedSlashInput } from './types'; |
| 2 | |
| 3 | export function parseSlashInput(input: string): ParsedSlashInput | null { |
| 4 | if (!input.startsWith('/')) return null; |
| 5 | const trimmed = input.slice(1).trim(); |
| 6 | if (trimmed.length === 0) return null; |
| 7 | const spaceIdx = trimmed.indexOf(' '); |
| 8 | const name = spaceIdx === -1 ? trimmed : trimmed.slice(0, spaceIdx); |
| 9 | const args = spaceIdx === -1 ? '' : trimmed.slice(spaceIdx + 1).trim(); |
| 10 | // Reject file paths (e.g. `/usr/local/bin`), but allow namespaced plugin |
| 11 | // commands whose name itself contains `/` (e.g. `plugin:frontend/component`). |
| 12 | if (name.includes('/') && !name.includes(':')) return null; |
| 13 | return { name, args }; |
| 14 | } |
no outgoing calls
no test coverage detected