File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,25 @@ Content with <special> characters & symbols.
363363 expect ( page . length ) . toBe ( 1 )
364364 } )
365365
366+ it ( 'should decode URL-encoded paths correctly' , async ( ) => {
367+ const cheerio = await import ( 'cheerio' )
368+ const $ = cheerio . load ( mockLlmsFullTxt , { xmlMode : true } )
369+
370+ // Simulate URL-encoded path as it comes from MCP SDK
371+ // Path /api/hooks/use-frame is encoded as %2Fapi%2Fhooks%2Fuse-frame
372+ const urlEncodedPath = '%2Fapi%2Fhooks%2Fuse-frame'
373+ const decodedPath = decodeURIComponent ( urlEncodedPath )
374+
375+ // After decoding, path already has leading slash, don't add another
376+ const searchPath = decodedPath . startsWith ( '/' ) ? decodedPath : `/${ decodedPath } `
377+
378+ expect ( searchPath ) . toBe ( '/api/hooks/use-frame' ) // Should NOT be //api/hooks/use-frame
379+
380+ const page = $ ( 'page' ) . filter ( ( _ , el ) => $ ( el ) . attr ( 'path' ) === searchPath )
381+ expect ( page . length ) . toBe ( 1 )
382+ expect ( page . attr ( 'title' ) ) . toBe ( 'useFrame Hook' )
383+ } )
384+
366385 it ( 'should format resource response correctly' , async ( ) => {
367386 const cheerio = await import ( 'cheerio' )
368387 const $ = cheerio . load ( mockLlmsFullTxt , { xmlMode : true } )
You can’t perform that action at this time.
0 commit comments