public function testBasicSetRawQuery() { $value = 'ana=mere&test=123'; $test = ['ana' => 'mere', 'test' => 123]; $url = new Url(); $url->setRawQuery($value); $this->assertEquals($test, $url->getQuery()); }
/** * This exists as the php::parse_url function sometimes breaks inexplicably * @param string $sUrl * @return Url */ protected static function parse_url($sUrl = null) { if (is_null($sUrl)) { return new Url(); } if (mb_detect_encoding($sUrl) !== 'ASCII') { $sUrl = rawurlencode($sUrl); } $oUrl = new Url(); try { if (!stristr($sUrl, '://') && is_file($sUrl) && is_readable($sUrl)) { $oUrl->setScheme('file'); $oUrl->setPath($sUrl); return $oUrl; } } catch (\Exception $e) { // possible open basedir restriction $oUrl->setScheme('file'); $oUrl->setPath($sUrl); return $oUrl; } try { if (!self::urlHasScheme($sUrl)) { $sUrl = (HttpRequestA::isSecure() ? 'https:' : 'http:') . $sUrl; } $aParsed = parse_url($sUrl); if (!is_array($aParsed)) { return null; } if (isset($aParsed['scheme'])) { $oUrl->setScheme($aParsed['scheme']); } if (isset($aParsed['host'])) { $oUrl->setHost($aParsed['host']); } if (isset($aParsed['port'])) { $oUrl->setPort($aParsed['port']); } if (isset($aParsed['path'])) { $oUrl->setPath($aParsed['path']); } if (isset($aParsed['query'])) { $oUrl->setRawQuery($aParsed['query']); } if (isset($aParsed['fragment'])) { $oUrl->setFragment($aParsed['fragment']); } return $oUrl; } catch (\Exception $e) { // failed php::parse_url } }