import { IncomingMessage , ServerResponse } from 'http' ; import { parse } from 'url' ; const func = ( req , res ) => { if ( req . url ) { const url = parse ( req . url ) ; let pathname = url . pathname ; if ( pathname && pathname . slice ( - 1 ) === '/' ) { pathname = pathname . replace ( /^\/+/g , '/' ) ; const location = pathname . slice ( 0 , - 1 ) + ( url . search ? url . search : '' ) ; res . end ( `trailing-redirect:RANDOMNESS_PLACEHOLDER:${ location }` ) ; } } } ; export default func ;