@@ -341,6 +341,54 @@ describe('RPCServer', function(){
341
341
342
342
} ) ;
343
343
344
+ it ( 'should correctly parse endpoints with double slashes and dots' , async ( ) => {
345
+
346
+ const identity = 'XX' ;
347
+ const { endpoint, close, server} = await createServer ( { } ) ;
348
+
349
+ try {
350
+ const endpointPaths = [
351
+ { append : '/ocpp' , expect : '/ocpp' } ,
352
+ { append : '//' , expect : '//' } ,
353
+ { append : '//ocpp' , expect : '//ocpp' } ,
354
+ { append : '/ocpp/' , expect : '/ocpp/' } ,
355
+ { append : '/' , expect : '/' } ,
356
+ { append : '///' , expect : '///' } ,
357
+ { append : '/../' , expect : '/' } ,
358
+ { append : '//../' , expect : '/' } ,
359
+ { append : '/ocpp/..' , expect : '/' } ,
360
+ { append : '/ocpp/../' , expect : '/' } ,
361
+ { append : '//ocpp/../' , expect : '//' } ,
362
+ { append : '' , expect : '/' } ,
363
+ ] ;
364
+
365
+ for ( const endpointPath of endpointPaths ) {
366
+ const fullEndpoint = endpoint + endpointPath . append ;
367
+
368
+ let hs ;
369
+ server . auth ( ( accept , reject , handshake ) => {
370
+ hs = handshake ;
371
+ accept ( ) ;
372
+ } ) ;
373
+
374
+ const cli = new RPCClient ( {
375
+ endpoint : fullEndpoint ,
376
+ identity,
377
+ } ) ;
378
+
379
+ await cli . connect ( ) ;
380
+ await cli . close ( { force : true } ) ;
381
+
382
+ assert . equal ( hs . endpoint , endpointPath . expect ) ;
383
+ assert . equal ( hs . identity , identity ) ;
384
+ }
385
+
386
+ } finally {
387
+ close ( ) ;
388
+ }
389
+
390
+ } ) ;
391
+
344
392
it ( 'should attach session properties to client' , async ( ) => {
345
393
346
394
let serverClient ;
0 commit comments