ramiismail/dopresskit — pull request #4 by nickgravelyn (2013-11-28 17:24:32+00:00)
Title: LinkParser broken

I think this is the fix for what you describe in issue #1. The description wasn't super clear to me but I think I found the issue anyway.

I quickly tested it on http://writecodeonline.com/php/:

function parseHubLink($uri)
{
$parsed = trim($uri);
if( strpos($parsed, "http://") === 0 )
$parsed = substr($parsed, 7);
if (strpos($parsed, "https://") === 0 )
$parsed = substr($parsed, 8);
if( strpos($parsed, "www.") === 0 )
$parsed = substr($parsed, 4);
if( strrpos($parsed, "/") === strlen($parsed) - 1)
$parsed = substr($parsed, 0, strlen($parsed) - 1);
return $parsed;
}

echo(parseHubLink("http://google.com/"));
echo("
");
echo(parseHubLink("http://google.com"));
echo("
");
echo(parseHubLink("http://google.com/blah/"));
echo("
");
echo(parseHubLink("http://twitter.com/nickgravelyn"));

The resulting output:

google.com
google.com
google.com/blah
twitter.com/nickgravelyn

So even in cases where you end the link with a slash, the parsed out URL comes back without it.