Skip to content

Commit

Permalink
Url: fixed isEqual() for same param values & regular sorting on numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Apr 7, 2015
1 parent 2d43b10 commit c84f4fd
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 c84f4fd

Please sign in to comment.