You are here

public function S3fsCssOptimizer::rewriteFileURI in S3 File System 8.2

Return absolute urls to access static files that they aren't in S3 bucket.

Parameters

array $matches: An array of matches by a preg_replace_callback() call that scans for url() references in CSS files, except for external or absolute ones.

Return value

string The file path.

Overrides CssOptimizer::rewriteFileURI

File

src/S3fsCssOptimizer.php, line 22

Class

S3fsCssOptimizer
Optimizes a CSS asset.

Namespace

Drupal\s3fs

Code

public function rewriteFileURI($matches) {

  // Prefix with base and remove '../' segments where possible.
  $path = $this->rewriteFileURIBasePath . $matches[1];
  $last = '';
  while ($path != $last) {
    $last = $path;
    $path = preg_replace('`(^|/)(?!\\.\\./)([^/]+)/\\.\\./`', '$1', $path);
  }
  return 'url(' . file_create_url($path) . ')';
}