mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
Fix asset URL generation
This is important when Flarum is deployed in a subfolder. Closes #291.
This commit is contained in:
@@ -306,7 +306,7 @@ class User extends Model
|
|||||||
{
|
{
|
||||||
$urlGenerator = app('Flarum\Http\UrlGeneratorInterface');
|
$urlGenerator = app('Flarum\Http\UrlGeneratorInterface');
|
||||||
|
|
||||||
return $this->avatar_path ? $urlGenerator->toAsset('assets/avatars/'.$this->avatar_path) : null;
|
return $this->avatar_path ? $urlGenerator->toAsset('avatars/'.$this->avatar_path) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Flarum\Http;
|
namespace Flarum\Http;
|
||||||
|
|
||||||
|
use Flarum\Core;
|
||||||
|
|
||||||
class UrlGenerator implements UrlGeneratorInterface
|
class UrlGenerator implements UrlGeneratorInterface
|
||||||
{
|
{
|
||||||
protected $routes;
|
protected $routes;
|
||||||
@@ -26,12 +28,11 @@ class UrlGenerator implements UrlGeneratorInterface
|
|||||||
$path = $this->routes->getPath($name, $parameters);
|
$path = $this->routes->getPath($name, $parameters);
|
||||||
$path = ltrim($path, '/');
|
$path = ltrim($path, '/');
|
||||||
|
|
||||||
// TODO: Prepend real base URL
|
return Core::url() . "/$path";
|
||||||
return "/$path";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toAsset($path)
|
public function toAsset($path)
|
||||||
{
|
{
|
||||||
return "/$path";
|
return Core::url() . "/assets/$path";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user