diff options
author | Matt Friedman <maf675@gmail.com> | 2011-09-25 18:16:25 -0700 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2011-09-26 11:16:10 -0700 |
commit | abb0f3f96d2fecfe2af2bde539a2b9d3a577e421 (patch) | |
tree | 8471648b6ae8c8836e178546feb260f9a9cef8ea /phpBB/includes/functions.php | |
parent | 39840ef36d4b074478de080caddd3e880bdba663 (diff) | |
download | forums-abb0f3f96d2fecfe2af2bde539a2b9d3a577e421.tar forums-abb0f3f96d2fecfe2af2bde539a2b9d3a577e421.tar.gz forums-abb0f3f96d2fecfe2af2bde539a2b9d3a577e421.tar.bz2 forums-abb0f3f96d2fecfe2af2bde539a2b9d3a577e421.tar.xz forums-abb0f3f96d2fecfe2af2bde539a2b9d3a577e421.zip |
[ticket/10390] Improve the jQuery CDN url generation function
Per p's comments, return the remote url from a variable instead of
using multiple returns. Also put the logic for creating Google's version
on its own line, and count the version number's dots instead of length
so it will be less likely to break if jQuery goes to version 1.10.
PHPBB3-10390
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index af07938879..83cadf426d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4781,18 +4781,21 @@ function remote_jquery_url($host) switch($host) { case 'google': - // Google uses a 1.5.0, 1.5.1 format (it is always a three numbered version) - return '//ajax.googleapis.com/ajax/libs/jquery/' . ((strlen(JQUERY_VERSION) == 3) ? JQUERY_VERSION . '.0' : JQUERY_VERSION) . '/jquery.min.js'; + // Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases) + $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; + // HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS + $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; break; case 'microsoft': // Microsoft uses a 1.5, 1.5.1 format - return 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + $url = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; break; case 'jquery': // jQuery uses a 1.5, 1.5.1 format - return 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; + $url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; break; } + return $url; } |