function make_valid_url

8.0.x make.utilities.inc make_valid_url($url, $absolute = FALSE)
6.x make.utilities.inc make_valid_url($url, $absolute = FALSE)
7.x make.utilities.inc make_valid_url($url, $absolute = FALSE)
5.x make.utilities.inc make_valid_url($url, $absolute = FALSE)
master make.utilities.inc make_valid_url($url, $absolute = FALSE)

Verify the syntax of the given URL.

Copied verbatim from includes/common.inc

See also

valid_url

1 call to make_valid_url()
make_parse_info_file in commands/make/make.utilities.inc
Parse Drupal info file format.

File

commands/make/make.utilities.inc, line 287
General utility functions for Drush Make.

Code

function make_valid_url($url, $absolute = FALSE) {
  if ($absolute) {
    return (bool) preg_match("
      /^                                                      # Start at the beginning of the text
      (?:ftp|https?):\/\/                                     # Look for ftp, http, or https schemes
      (?:                                                     # Userinfo (optional) which is typically
        (?:(?:[\w\.\-\+!$&'\(\)*\+,;=]|%[0-9a-f]{2})+:)*      # a username or a username and password
        (?:[\w\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})+@          # combination
      )?
      (?:
        (?:[a-z0-9\-\.]|%[0-9a-f]{2})+                        # A domain name or a IPv4 address
        |(?:\[(?:[0-9a-f]{0,4}:)*(?:[0-9a-f]{0,4})\])         # or a well formed IPv6 address
      )
      (?::[0-9]+)?                                            # Server port number (optional)
      (?:[\/|\?]
        (?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})   # The path and query (optional)
      *)?
    $/xi", $url);
  }
  else {
    return (bool) preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
  }
}