stripExtensionFromLastSegment would be slightly more accurate