(sessionId: string)
| 22 | |
| 23 | /** Validate a session id and return it, or throw. */ |
| 24 | export function assertSessionId(sessionId: string): string { |
| 25 | if (sessionId.length === 0) { |
| 26 | throw new InvalidSessionIdError(sessionId, "must not be empty"); |
| 27 | } |
| 28 | if (!VALID_REPO_NAME.test(sessionId)) { |
| 29 | throw new InvalidSessionIdError(sessionId, VALID_REPO_NAME_DESCRIPTION); |
| 30 | } |
| 31 | if (sessionId.includes(SCOPE_SEPARATOR)) { |
| 32 | throw new InvalidSessionIdError(sessionId, `must not contain '${SCOPE_SEPARATOR}'`); |
| 33 | } |
| 34 | return sessionId; |
| 35 | } |
| 36 | |
| 37 | /** Validate a local repo name and return it, or throw. */ |
| 38 | export function assertLocalName(name: string): string { |
no outgoing calls
no test coverage detected