php/WP_CLI/FileCache.php
protected function validate_key( $key ) {
		$url_parts = Utils\parse_url( $key, -1, false );
		if ( ! empty( $url_parts['scheme'] ) ) { // is url
			$parts   = array( 'misc' );
			$parts[] = $url_parts['scheme'] . '-' . $url_parts['host'] .
				( empty( $url_parts['port'] ) ? '' : '-' . $url_parts['port'] );
			$parts[] = substr( $url_parts['path'], 1 ) .
				( empty( $url_parts['query'] ) ? '' : '-' . $url_parts['query'] );
		} else {
			$key   = str_replace( '\\', '/', $key );
			$parts = explode( '/', ltrim( $key ) );
		}

		$parts = preg_replace( "#[^{$this->whitelist}]#i", '-', $parts );

		return implode( '/', $parts );
	}
protected function validate_key( $key ) {
		$url_parts = Utils\parse_url( $key, -1, false );
		if ( ! empty( $url_parts['scheme'] ) ) { // is url
			$parts   = array( 'misc' );
			$parts[] = $url_parts['scheme'] . '-' . $url_parts['host'] .
				( empty( $url_parts['port'] ) ? '' : '-' . $url_parts['port'] );
			$parts[] = substr( $url_parts['path'], 1 ) .
				( empty( $url_parts['query'] ) ? '' : '-' . $url_parts['query'] );
		} else {
			$key   = str_replace( '\\', '/', $key );
			$parts = explode( '/', ltrim( $key ) );
		}

		$parts = preg_replace( "#[^{$this->whitelist}]#i", '-', $parts );

		return implode( '/', $parts );
	}
protected function validate_key ( $ key ) { $ url_parts = Utils \ parse_url ( $ key , - 1 , false ) ; if ( ! empty ( $ url_parts [ 'scheme' ] ) ) { // is url $ parts = array ( 'misc' ) ; $ parts [ ] = $ url_parts [ 'scheme' ] . '-' . $ url_parts [ 'host' ] . ( empty ( $ url_parts [ 'port' ] ) ? '' : '-' . $ url_parts [ 'port' ] ) ; $ parts [ ] = substr ( $ url_parts [ 'path' ] , 1 ) . ( empty ( $ url_parts [ 'query' ] ) ? '' : '-' . $ url_parts [ 'query' ] ) ; } else { $ key = str_replace ( '\\' , '/' , $ key ) ; $ parts = explode ( '/' , ltrim ( $ key ) ) ; } $ parts = preg_replace ( "#[^{$this->whitelist}]#i" , '-' , $ parts ) ; return implode ( '/' , $ parts ) ; }
Validate cache key

@param string $key cache key
@return string relative filename
Validate cache key