Implement ensure_endswith and use in _sanitize_pattern