function testCombineRelativePathWithBasePath()
 {
     $this->assertEquals('/foo/bar/boo', UriResolver::combineRelativePathWithBasePath('boo', '/foo/bar/'));
     $this->assertEquals('/foo/bar/', UriResolver::combineRelativePathWithBasePath('', '/foo/bar/'));
     $this->assertEquals('/foo/bar', UriResolver::combineRelativePathWithBasePath('', '/foo/bar'));
     // ??? imho /boo
     $this->assertEquals('/foo/bar/boo', UriResolver::combineRelativePathWithBasePath('/boo', '/foo/bar/'));
     $this->assertEquals('/foo.json', UriResolver::combineRelativePathWithBasePath('', '/foo.json'));
 }
Example #2
0
 public function testCombineRelativePathWithBasePathNoPath()
 {
     //needed for anchor-only urls
     $this->assertEquals('/foo/bar.json', UriResolver::combineRelativePathWithBasePath('', '/foo/bar.json'));
 }
Example #3
0
 /**
  * Resolves a URI
  *
  * @param string $uri Absolute or relative
  * @param string $baseUri Optional base URI
  * @return string
  */
 public function resolve($uri, $baseUri = null)
 {
     $components = $this->parse($uri);
     $path = $components['path'];
     if (array_key_exists('scheme', $components) && 'http' === $components['scheme']) {
         return $uri;
     }
     $baseComponents = $this->parse($baseUri);
     $basePath = $baseComponents['path'];
     $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
     return $this->generate($baseComponents);
 }