Skip to content

Commit

Permalink
Merge pull request #59 from hrach/url-isequal
Browse files Browse the repository at this point in the history
Url: fixed isEqual() for same param values & regular sorting on numbers
  • Loading branch information
dg committed Apr 8, 2015
2 parents 2d43b10 + c84f4fd commit c682f0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Http/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ public function isEqual($url)
{
$url = new self($url);
$query = $url->query;
sort($query);
ksort($query);
$query2 = $this->query;
sort($query2);
ksort($query2);
$http = in_array($this->scheme, array('http', 'https'), TRUE);
return $url->scheme === $this->scheme
&& !strcasecmp($url->host, $this->host)
Expand Down
8 changes: 8 additions & 0 deletions tests/Http/Url.isEqual().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Assert::true( $url->isEqual('http://example.com/?arr[0]=item1&arr[1]=item2') );
Assert::false( $url->isEqual('http://example.com/?arr[1]=item1&arr[0]=item2') );


$url = new Url('http://example.com/?a=9999&b=127.0.0.1&c=1234&d=123456789');
Assert::true( $url->isEqual('http://example.com/?d=123456789&a=9999&b=127.0.0.1&c=1234') );


$url = new Url('http://example.com/?a=123&b=456');
Assert::false( $url->isEqual('http://example.com/?a=456&b=123') );


$url = new Url('http://user:[email protected]');
Assert::true( $url->isEqual('http://example.com') );

Expand Down

0 comments on commit c682f0f

Please sign in to comment.