<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -51,7 +51,7 @@ class CanonicalLink {
 			// Redirection taking place
 			//echo &quot;Response: &quot;; print_r($response);
 			$location = $response-&gt;getHeader('Location');
-			//echo &quot;Response redirecting to: {$location}\n&quot;;
+			echo &quot;Response redirecting to: {$location}\n&quot;;
 			if (!$location) { 
 				echo &quot;WARN: Response Redirect Location could not be determined.\n&quot;;
 				print_r($response);
@@ -59,16 +59,21 @@ class CanonicalLink {
 			}
 			
 			if (!preg_match('/^\w+:/', $location)) {
-				//echo &quot;WARN: Relative link in HTTP redirect Location: {$location}\n&quot;;
 				$relativeUrl = new HttpUrl($url);
 				$relativeUrl-&gt;setRelativeUrl($location);
 				$location = $relativeUrl-&gt;getUrl();
+
+				if ($location===$url) {
+					//echo &quot;WARN: Relative link in HTTP redirect Location: {$location} from {$url}\n&quot;;
+					return NULL;
+				}
 			}
 			
 			// TODO: Keep following the redirection until we arrive at
 			//			a non-redirecting page
 			if ($follow) {
 				$newLocation = $this-&gt;getCanonicalLink($location, true, $depth++);
+	
 				if (!is_null($newLocation) &amp;&amp; $newLocation!=$location) {
 					$location = $newLocation;
 				}</diff>
      <filename>CanonicalLink.php</filename>
    </modified>
    <modified>
      <diff>@@ -40,7 +40,7 @@ class CanonicalLinkTest extends PHPUnit_Framework_TestCase {
 ****/
 
 
-// ****
+/****
 	public function testNormalUrl() {
 		$url = 'http://www.isolani.co.uk/';
 		$canonUrl = $this-&gt;canon-&gt;getCanonicalLink($url);
@@ -256,18 +256,16 @@ class CanonicalLinkTest extends PHPUnit_Framework_TestCase {
 		$canonUrl = $this-&gt;canon-&gt;getCanonicalLink($url);
 		$this-&gt;assertEquals($endUrl, $canonUrl);
 	}
-// ****/
+****/
 
 
 	
-// ****
 	public function testMultipleRedirectUrl() {
 		$url      = 'http://ping.fm/lzYNA';
 		$endUrl   = 'http://web.me.com/abrightman/DisabilityLand/';
 		$canonUrl = $this-&gt;canon-&gt;getCanonicalLink($url);
 		$this-&gt;assertEquals($endUrl, $canonUrl);
 	}
-// ****/
 
 	public function testLowerCaseLocationRedirect() {
 		//echo ucwords('link-farm');
@@ -280,6 +278,17 @@ class CanonicalLinkTest extends PHPUnit_Framework_TestCase {
 		$this-&gt;assertEquals($endUrl, $canonUrl);
 	}
 
+	
+	public function testRelativeInfiniteRedirect() {
+		$url      = &quot;http://bit.ly/28RAOP&quot;;
+		$endUrl   = 'http://www.canadianarchitect.com/common_scripts/browse/default.asp?aid=1000208224';
+		//echo &quot;Start link: {$url}\n&quot;;
+		$canonUrl = $this-&gt;canon-&gt;getCanonicalLink($url);
+		//echo &quot;CanonURL link: {$canonUrl}\n&quot;;
+		$this-&gt;assertEquals($endUrl, $canonUrl);
+	}
+
+
 }
 
 </diff>
      <filename>tests/CanonicalLinkTest.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>818e4b31816e042b87031fb8854edc1749485467</id>
    </parent>
  </parents>
  <author>
    <name>Isofarro</name>
    <email>isofarro2@gmail.com</email>
  </author>
  <url>http://github.com/isofarro/php5-http-utils/commit/1f9b30ad4d46a1c4dda1fe6a52f42387f302e9de</url>
  <id>1f9b30ad4d46a1c4dda1fe6a52f42387f302e9de</id>
  <committed-date>2009-10-15T12:27:52-07:00</committed-date>
  <authored-date>2009-10-15T12:27:52-07:00</authored-date>
  <message>Detecting infinite redirects of relative URLs</message>
  <tree>c83df0e3fe1c72cd380f38ebbf11d65558ad69e7</tree>
  <committer>
    <name>Isofarro</name>
    <email>isofarro2@gmail.com</email>
  </committer>
</commit>
