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 {
4949 } ) ;
5050
5151 // 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 ( '?' ) ? '&' : '?' ;
5261 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` ,
5463 ) ;
5564
5665 this . _sseResponse = this . res ;
You can’t perform that action at this time.
0 commit comments