Commit 585e025e authored by alexpott's avatar alexpott
Browse files

Issue #2276203 by webflo, lauriii, nlisgo, kallehauge, Snipon: Fixed CSS...

Issue #2276203 by webflo, lauriii, nlisgo, kallehauge, Snipon: Fixed CSS Aggregation breaks URLs with Query String.
parent d07587ec
......@@ -323,7 +323,19 @@ function file_create_url($uri) {
else {
// If this is not a properly formatted stream, then it is a shipped file.
// Therefore, return the urlencoded URI with the base URL prepended.
return $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($uri);
$options = UrlHelper::parse($uri);
$path = $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($options['path']);
// Append the query.
if ($options['query']) {
$path .= '?' . UrlHelper::buildQuery($options['query']);
}
// Append fragment.
if ($options['fragment']) {
$path .= '#' . $options['fragment'];
}
return $path;
}
}
elseif ($scheme == 'http' || $scheme == 'https' || $scheme == 'data') {
......
......@@ -56,6 +56,18 @@ function testShippedFileURL() {
$filepath = 'core/misc/favicon.ico';
$url = file_create_url($filepath);
$this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.');
// Test alteration of file URLs with query strings and/or fragment.
\Drupal::state()->delete('file_test.hook_file_url_alter');
$filepath = 'core/misc/favicon.ico';
$url = file_create_url($filepath . '?foo');
$this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=', $url, 'Correctly generated url. The query string is present.');
$url = file_create_url($filepath . '?foo=bar');
$this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar', $url, 'Correctly generated url. The query string is present.');
$url = file_create_url($filepath . '#v1.2');
$this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '#v1.2', $url, 'Correctly generated url. The fragment is present.');
$url = file_create_url($filepath . '?foo=bar#v1.2');
$this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar#v1.2', $url, 'Correctly generated url. The query string amd fragment is present.');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment