Created
May 12, 2010 05:22
-
-
Save davidrecordon/398238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// turn what we figured out the user entered into a canonicalized string. | |
// $parsed is a hash with keys of scheme, user, domain, port, and path. | |
function normalize_input($parsed) { | |
$identifier = ''; | |
if ($parsed['scheme'] == 'acct') { | |
$identifier = 'acct:' . $parsed['user'] . '@' . $parsed['domain']; | |
} else { | |
$identifier = $parsed['scheme'] . '://' . $parsed['domain']; | |
if ($parsed['port']) { | |
$identifier .= ':' . $parsed['port']; | |
} | |
$identifier .= $parsed['path'] ? $parsed['path'] : '/'; | |
} | |
return $identifier; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment