function follow_parse_url in Follow 7.2
Same name and namespace in other branches
- 5 follow.module \follow_parse_url()
- 6 follow.module \follow_parse_url()
- 7 follow.module \follow_parse_url()
Split a Drupal path or external link into path and options like a menu link.
2 calls to follow_parse_url()
- follow_link_save in ./
follow.inc - Inserts a new link, or updates an existing one.
- follow_url_validate in ./
follow.inc - Validates the url field to verify it's actually a url.
File
- ./
follow.inc, line 187 - Follow module API and helper functions.
Code
function follow_parse_url($url) {
$parsed_url = parse_url($url);
$defaults = array(
'scheme' => '',
'host' => '',
'port' => '',
'path' => '/',
'query' => '',
'fragment' => '',
);
$parsed_url += $defaults;
$options = array(
'query' => array(),
'fragment' => $parsed_url['fragment'],
);
// Parse the query string into an array.
parse_str($parsed_url['query'], $options['query']);
if ($parsed_url['scheme']) {
$parsed_url['scheme'] .= '://';
}
// Throw away port for now.
$path = $parsed_url['scheme'] . $parsed_url['host'] . $parsed_url['path'];
return array(
'path' => $path,
'options' => $options,
);
}