Permalink
Browse files

[DomCrawler] Fixed handling of relative query strings as links

  • Loading branch information...
1 parent a4451b4 commit d49e306b9b4fe0f26db8775fd29da650b89e4f85 @asm89 committed Jun 22, 2011
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/Symfony/Component/DomCrawler/Link.php
@@ -89,11 +89,23 @@ public function getUri()
return $this->currentUri;
}
- // only an anchor or a query string
- if (in_array($uri[0], array('?', '#'))) {
+ // only an anchor
+ if ('#' === $uri[0]) {
return $this->currentUri.$uri;
}
+ // only a query string
+ if ('?' === $uri[0] ) {
+ $baseUri = $this->currentUri;
+
+ // remove the query string from the current uri
+ if (false !== ($pos = strpos($this->currentUri, '?'))) {
+ $baseUri = substr($this->currentUri, 0, strpos($this->currentUri, '?'));
+ }
+
+ return $baseUri.$uri;
+ }
+
// absolute path
if ('/' === $uri[0]) {
return preg_replace('#^(.*?//[^/]+)(?:\/.*)?$#', '$1', $this->currentUri).$uri;

0 comments on commit d49e306

Please sign in to comment.