diff options
author | Jennifer Hodgdon <yahgrp@poplarware.com> | 2014-06-13 15:24:43 -0700 |
---|---|---|
committer | Jennifer Hodgdon <yahgrp@poplarware.com> | 2014-06-13 15:24:43 -0700 |
commit | 921d9dd084e35f361e8ba6f2f0051ec3902c0666 (patch) | |
tree | 29a2b69fa4f61853ce4ee123583ea8fbe9768c90 /includes/common.inc | |
parent | aeb6f56ad902569bb888808bea2650a246e7231b (diff) | |
download | brdo-921d9dd084e35f361e8ba6f2f0051ec3902c0666.tar.gz brdo-921d9dd084e35f361e8ba6f2f0051ec3902c0666.tar.bz2 |
Issue #2277623 by mparker17: Fix up docs for drupal_parse_url function
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/includes/common.inc b/includes/common.inc index e1a1673d7..477ecc0e2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -544,37 +544,32 @@ function drupal_get_destination() { } /** - * Parses a system URL string into an associative array suitable for url(). + * Parses a URL string into its path, query, and fragment components. * - * This function should only be used for URLs that have been generated by the - * system, such as via url(). It should not be used for URLs that come from - * external sources, or URLs that link to external resources. + * This function splits both internal paths like @code node?b=c#d @endcode and + * external URLs like @code https://example.com/a?b=c#d @endcode into their + * component parts. See + * @link http://tools.ietf.org/html/rfc3986#section-3 RFC 3986 @endlink for an + * explanation of what the component parts are. * - * The returned array contains a 'path' that may be passed separately to url(). - * For example: - * @code - * $options = drupal_parse_url($_GET['destination']); - * $my_url = url($options['path'], $options); - * $my_link = l('Example link', $options['path'], $options); - * @endcode + * Note that, unlike the RFC, when passed an external URL, this function + * groups the scheme, authority, and path together into the path component. * - * This is required, because url() does not support relative URLs containing a - * query string or fragment in its $path argument. Instead, any query string - * needs to be parsed into an associative query parameter array in - * $options['query'] and the fragment into $options['fragment']. - * - * @param $url - * The URL string to parse, f.e. $_GET['destination']. + * @param string $url + * The internal path or external URL string to parse. * - * @return - * An associative array containing the keys: - * - 'path': The path of the URL. If the given $url is external, this includes - * the scheme and host. - * - 'query': An array of query parameters of $url, if existent. - * - 'fragment': The fragment of $url, if existent. + * @return array + * An associative array containing: + * - path: The path component of $url. If $url is an external URL, this + * includes the scheme, authority, and path. + * - query: An array of query parameters from $url, if they exist. + * - fragment: The fragment component from $url, if it exists. * - * @see url() * @see drupal_goto() + * @see l() + * @see url() + * @see http://tools.ietf.org/html/rfc3986 + * * @ingroup php_wrappers */ function drupal_parse_url($url) { |