1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Properly transform Celerity resource URIs with query strings and anchors

Summary:
See <6a45b7e670>

These URIs have "?hack=iefix#ieieielol" on them, which the parser doesn't recognize as a known resource, so it errs on the side of caution by not rewriting.

Instead, strip this bit off, attempt to rewrite, then put it back on.

Test Plan: Loaded `font-awesome.css` locally and saw properly rewritten URIs.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9153
This commit is contained in:
epriestley 2014-05-16 09:27:39 -07:00
parent 715bf1fd55
commit 0b4f2c8508

View file

@ -111,6 +111,17 @@ final class CelerityResourceTransformer {
public function translateResourceURI(array $matches) {
$uri = trim($matches[1], "'\" \r\t\n");
$tail = '';
// If the resource URI has a query string or anchor, strip it off before
// we go looking for the resource. We'll stitch it back on later. This
// primarily affects FontAwesome.
$parts = preg_split('/(?=[?#])/', $uri, 2);
if (count($parts) == 2) {
$uri = $parts[0];
$tail = $parts[1];
}
$alternatives = array_unique(
array(
@ -142,7 +153,7 @@ final class CelerityResourceTransformer {
}
}
return 'url('.$uri.')';
return 'url('.$uri.$tail.')';
}
private function replaceCSSVariables($path, $data) {