function javascript_libraries_valid_external_url in JavaScript Libraries Manager 7
Same name and namespace in other branches
- 8 javascript_libraries.module \javascript_libraries_valid_external_url()
Determines if a URL is a valid external JavaScript library URL.
Parameters
$url: The URL to check.
Return value
TRUE if the URL is a valid external JavaScript library URL, or FALSE if it isn't.
2 calls to javascript_libraries_valid_external_url()
- drush_javascript_libraries_jslib_switch_url in ./
javascript_libraries.drush.inc - Drush command callback; switches the URL of an external JavaScript library.
- _javascript_libraries_url_validate in ./
javascript_libraries.admin.inc
File
- ./
javascript_libraries.module, line 144 - Toggle the inclusion of Drupal system libraries. Upload and reference custom libraries as well.
Code
function javascript_libraries_valid_external_url($url) {
// The URL must begin with http:// or https:// and must end in ".js" or
// ".txt".
$parts = parse_url($url);
return $parts && ($parts['scheme'] == 'http' || $parts['scheme'] == 'https') && $parts['host'] && preg_match('@/.+\\.(js|txt)$@i', $parts['path']);
}