public static function parseURL( $url, $defaults = array() ) {

		$parts = is_string($url) ? \parse_url(urldecode($url)) : $url;

		$select = function( $k ) use ( $parts, $defaults ) {
			if( isset($parts[$k]) )
				return $parts[$k];
			elseif( isset($defaults[$k]) )
				return $defaults[$k];
			else
				return '';
		};

		$url = array(
			'scheme'  => $select('scheme'),
			'host'    => $select('host'),
			'port'    => $select('port'),
			'user'    => $select('user'),
			'pass'    => $select('pass'),
			'path'    => $select('path'),
			'options' => array(),
		);

		if( isset($parts['query']) )
			parse_str($parts['query'], $url['options']);

		return $url;

	}