MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseSessionIdentifier

Function parseSessionIdentifier

src/utils/sessionUrl.ts:20–64  ·  view source on GitHub ↗
(
  resumeIdentifier: string,
)

Source from the content-addressed store, hash-verified

18 * @returns Parsed session information or null if invalid
19 */
20export function parseSessionIdentifier(
21 resumeIdentifier: string,
22): ParsedSessionUrl | null {
23 // Check for JSONL file path before URL parsing, since Windows absolute
24 // paths (e.g., C:\path\file.jsonl) are parsed as valid URLs with C: as protocol
25 if (resumeIdentifier.toLowerCase().endsWith('.jsonl')) {
26 return {
27 sessionId: randomUUID() as UUID,
28 ingressUrl: null,
29 isUrl: false,
30 jsonlFile: resumeIdentifier,
31 isJsonlFile: true,
32 }
33 }
34
35 // Check if it's a plain UUID
36 if (validateUuid(resumeIdentifier)) {
37 return {
38 sessionId: resumeIdentifier as UUID,
39 ingressUrl: null,
40 isUrl: false,
41 jsonlFile: null,
42 isJsonlFile: false,
43 }
44 }
45
46 // Check if it's a URL
47 try {
48 const url = new URL(resumeIdentifier)
49
50 // Use the entire URL as the ingress URL
51 // Always generate a random session ID
52 return {
53 sessionId: randomUUID() as UUID,
54 ingressUrl: url.href,
55 isUrl: true,
56 jsonlFile: null,
57 isJsonlFile: false,
58 }
59 } catch {
60 // Not a valid URL
61 }
62
63 return null
64}
65

Callers 1

loadInitialMessagesFunction · 0.85

Calls 1

validateUuidFunction · 0.70

Tested by

no test coverage detected