question: static URL fixPureQueryTargets ( URL base , String target ) throws MalformedURLException { if ( ! target . startsWith ( "?" ) ) return new URL ( base , target ) ; String basePath = base . getPath ( ) ; String baseRightMost = "" ; int baseRightMostIdx = basePath . lastIndexOf ( "/" ) ; if ( baseRightMostIdx != - 1 ) { baseRightMost = basePath . substring ( baseRightMostIdx + 1 ) ; } if ( target . startsWith ( "?" ) ) target = baseRightMost + target ; return new URL ( base , target ) ; }
target:  Handle the case in RFC3986 section 5.4.1 example 7, and similar. 