diff --git a/cdn.basic.css.inc b/cdn.basic.css.inc index 8bba66c..c700a32 100644 --- a/cdn.basic.css.inc +++ b/cdn.basic.css.inc @@ -153,23 +153,26 @@ function _cdn_build_css_path($matches, $base = NULL) { } $parsed_url = parse_url($url); - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; - $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; - $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; - $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; - $pass = ($user !== '' || $pass !== '') ? "$pass@" : ''; - $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + $base_url = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $base_url .= isset($parsed_url['user']) ? $parsed_url['user'] : ''; + $base_url .= isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; + if (isset($parsed_url['user']) || isset($parsed_url['pass'])) { + $base_url .= '@'; + } + $base_url .= isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $base_url .= isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $base_url .= isset($parsed_url['path']) ? $parsed_url['path'] : ''; + + $query = isset($parsed_url['query']) ? $parsed_url['query'] : ''; // In the case of certain URLs, we may have simply a '?' character without // further parameters. parse_url() misses this and leaves 'query' blank, so // need to this back in. // See http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax // for more information. - if ($query === '' && strpos($url, $scheme . $user . $pass . $host . $port . $path . '?') === 0) { - $query = '?'; + if ($query != '' || strpos($url, $base_url . '?') === 0) { + $query = '?' . $query; } $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; - return 'url(' . file_create_url($scheme . $user . $pass . $host . $port . $path) . $query . $fragment . ')'; + return 'url(' . file_create_url($base_url) . $query . $fragment . ')'; } diff --git a/tests/cdn.test b/tests/cdn.test index 011f68e..b88a518 100644 --- a/tests/cdn.test +++ b/tests/cdn.test @@ -600,5 +600,4 @@ class CDNCssUrlTestCase extends DrupalWebTestCase { $this->fail($exc); } } - }