/** * Given 2 paths, will merge them according to rules set out in RFC 2986, * Section 5.2 * * @see http://tools.ietf.org/html/rfc3986#section-5.2.3 * * @param $path1 * @param $path2 */ protected function mergePaths(URI $base, URI $reference) { if (!empty($base->getAuthority()) && empty($base->getPath())) { return '/' . ltrim($base->getPath(), '/ '); } $path = explode('/', $base->getPath()); if (empty($path[0])) { unset($path[0]); } array_pop($path); array_push($path, $reference->getPath()); return implode('/', $path); }
public function testSetAuthorityReconstitutes() { $authority = 'me@foo.com:3000'; $uri = new URI(); $uri->setAuthority($authority); $this->assertEquals($authority, $uri->getAuthority()); }