Respect path-segment boundaries when stripping the configured base (#17701)