diff --git a/src/Mix.php b/src/Mix.php
index fd2a583..1eb7448 100644
--- a/src/Mix.php
+++ b/src/Mix.php
@@ -25,7 +25,8 @@ class Mix
*/
public function __invoke($path, $manifestDirectory = '')
{
- if (! starts_with($path, '/')) {
+ $path = preg_replace('/\?.*/', '', $path);
+ if ($path && ! starts_with($path, '/')) {
$path = "/{$path}";
}
diff --git a/tests/TestCase/View/Helper/AssetMixHelperTest.php b/tests/TestCase/View/Helper/AssetMixHelperTest.php
index 949de57..155af6c 100644
--- a/tests/TestCase/View/Helper/AssetMixHelperTest.php
+++ b/tests/TestCase/View/Helper/AssetMixHelperTest.php
@@ -26,7 +26,10 @@ public function setUp()
{
parent::setUp();
- mkdir(TEST_APP_DIR . 'webroot');
+ $webroot = TEST_APP_DIR . 'webroot';
+ if (! file_exists($webroot)) {
+ mkdir($webroot);
+ }
$view = new View();
$this->AssetMix = new AssetMixHelper($view);
@@ -155,6 +158,23 @@ public function testStyleTagWithVersion()
$this->assertContains('href="/css/main.css?id=9c4259d5465e35535a2a"', $result);
}
+ /**
+ * Test `css()` function returns proper tag
+ * with asset timestamping enabled
+ *
+ * @return void
+ */
+ public function testStyleTagWithTimestamp()
+ {
+ $this->_copyWithoutVersion();
+
+ $result = $this->AssetMix->css('main.css?1660315070');
+
+ $this->assertContains('assertContains('rel="stylesheet"', $result);
+ $this->assertContains('href="/css/main.css', $result);
+ }
+
/**
* Test `script()` function returns proper tag
* with versioning enabled
@@ -171,4 +191,21 @@ public function testScriptTagWithVersion()
$this->assertContains('/js/app.js?id=f059fcadc7eba26be9ae', $result);
$this->assertContains('defer="defer"', $result);
}
+
+ /**
+ * Test `script()` function returns proper tag
+ * with asset timestamping enabled
+ *
+ * @return void
+ */
+ public function testScriptTagWithTimestamp()
+ {
+ $this->_copyWithoutVersion();
+
+ $result = $this->AssetMix->script('app.js?1660315070');
+
+ $this->assertContains('