- // Strip the leading www. to be more forgiving on input URLs.
- $host = preg_replace('/^www\./', '', $url["host"]);
+ // if the host is not given derive it from the URL
+ if (NULL === $host) {
+ if (empty($url["host"])) {
+ trigger_error("Invalid host in URL: $src_url", E_USER_ERROR);
+ return NULL;
+ }
+ // Strip the leading www. to be more forgiving on input URLs.
+ $host = preg_replace('/^www\./', '', $url["host"]);
+ }