Skip to content

Commit 58cbcaa

Browse files
authored
[10.x] Handle relative ASSET_URL (#43900)
1 parent d6d92eb commit 58cbcaa

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Illuminate/Routing/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function asset($path, $secure = null)
255255
// for asset paths, but only for routes to endpoints in the application.
256256
$root = $this->assetRoot ?: $this->formatRoot($this->formatScheme($secure));
257257

258-
return $this->removeIndex($root).'/'.trim($path, '/');
258+
return Str::finish($this->removeIndex($root), '/').trim($path, '/');
259259
}
260260

261261
/**

tests/Routing/RoutingUrlGeneratorTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ public function testBasicGeneration()
4141
);
4242

4343
$this->assertSame('https://www.foo.com/foo/bar', $url->to('foo/bar'));
44+
}
4445

45-
/*
46-
* Test asset URL generation...
47-
*/
46+
public function testAssetGeneration()
47+
{
4848
$url = new UrlGenerator(
4949
new RouteCollection,
5050
Request::create('http://www.foo.com/index.php/')
5151
);
5252

5353
$this->assertSame('http://www.foo.com/foo/bar', $url->asset('foo/bar'));
5454
$this->assertSame('https://www.foo.com/foo/bar', $url->asset('foo/bar', true));
55+
56+
$url = new UrlGenerator(
57+
new RouteCollection,
58+
Request::create('http://www.foo.com/index.php/'),
59+
'/'
60+
);
61+
62+
$this->assertSame('/foo/bar', $url->asset('foo/bar'));
63+
$this->assertSame('/foo/bar', $url->asset('foo/bar', true));
5564
}
5665

5766
public function testBasicGenerationWithHostFormatting()

0 commit comments

Comments
 (0)