noindex for direct links to urls with facets when using yoast seo

/** experimental, use at your own risk, test throughly to not mess up your seo
 ** uses wpseo_robots from wordpress seo plugin (yoast) to change direct links
 ** for facet pages with facets in url from index to noindex in robots meta tag

add_filter( 'wpseo_robots', function( $robots ) {
    if ( function_exists( 'FWP' ) && ! FWP()->request->is_refresh && !empty( FWP()->request->url_vars )  ) {
        return str_replace( 'index', 'noindex', $robots);
    return $robots;