Skip to content

Instantly share code, notes, and snippets.

@davidrecordon
Created May 12, 2010 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrecordon/398238 to your computer and use it in GitHub Desktop.
Save davidrecordon/398238 to your computer and use it in GitHub Desktop.
<?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