File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,17 @@ export class SSEServerTransport implements Transport {
49
49
} ) ;
50
50
51
51
// Send the endpoint event
52
+ /**
53
+ * Determine the appropriate separator for adding the sessionId parameter.
54
+ * Uses '&' if the endpoint already contains a query parameter (has a '?'),
55
+ * otherwise uses '?' to start the query string.
56
+ *
57
+ * Note: This approach works for standard endpoints but doesn't handle
58
+ * the edge case where '?' might be part of the path itself.
59
+ */
60
+ const separator = this . _endpoint . includes ( '?' ) ? '&' : '?' ;
52
61
this . res . write (
53
- `event: endpoint\ndata: ${ encodeURI ( this . _endpoint ) } ? sessionId=${ this . _sessionId } \n\n` ,
62
+ `event: endpoint\ndata: ${ encodeURI ( this . _endpoint ) } ${ separator } sessionId=${ this . _sessionId } \n\n` ,
54
63
) ;
55
64
56
65
this . _sseResponse = this . res ;
You can’t perform that action at this time.
0 commit comments