(sessionPath: string | null | undefined)
| 18 | } |
| 19 | |
| 20 | function getLocalDraftParts(sessionPath: string | null | undefined) { |
| 21 | if (typeof sessionPath !== 'string' || !isLocalSessionPath(sessionPath)) { |
| 22 | return null |
| 23 | } |
| 24 | |
| 25 | const [, encodedProjectId = '', encodedChatGroupId = ''] = |
| 26 | sessionPath.match(localSessionPathPattern) ?? [] |
| 27 | if (encodedProjectId.length === 0) { |
| 28 | return null |
| 29 | } |
| 30 | |
| 31 | try { |
| 32 | return { |
| 33 | projectId: decodeURIComponent(encodedProjectId), |
| 34 | chatGroupId: encodedChatGroupId ? decodeURIComponent(encodedChatGroupId) : null, |
| 35 | } |
| 36 | } catch { |
| 37 | return null |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | export function getLocalDraftProjectId(sessionPath: string | null | undefined) { |
| 42 | return getLocalDraftParts(sessionPath)?.projectId ?? null |
no test coverage detected