public function testSetPathWhenExistingPathContainsEncodedUrl() { $url = new Url('http://example.com/task/http%3A%2F%2Fexample.com%2F/'); $url->setPath('/additional' . (string) $url->getPath()); $this->assertEquals('/additional/task/http%3A%2F%2Fexample.com%2F/', $url->getPath()); $this->assertEquals('http://example.com/additional/task/http%3A%2F%2Fexample.com%2F/', (string) $url); }
/** * Derive the path for a cookie from the request URL * * As defined in RFC6265: * 2. If the uri-path is empty or if the first character of the uri- * path is not a %x2F ("/") character, output %x2F ("/") and skip * the remaining steps. * * 3. If the uri-path contains no more than one %x2F ("/") character, * output %x2F ("/") and skip the remaining step. * * 4. Output the characters of the uri-path from the first character up * to, but not including, the right-most %x2F ("/"). * * @return string */ private function deriveCookiePathFromRequestUrl() { $path = $this->requestUrl->getPath(); if ($path->get() == '' || substr((string) $path, 0, 1) != '/') { return '/'; } if (substr_count((string) $path, '/') === 1) { return '/'; } return substr((string) $path, 0, strrpos((string) $path, '/')); }