X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/07b889547d28e68e5fc8f923c166bd607da17ad7..refs/pull/1688/head:/app/Entities/Chapter.php diff --git a/app/Entities/Chapter.php b/app/Entities/Chapter.php index bdacb7c9d..d121432fa 100644 --- a/app/Entities/Chapter.php +++ b/app/Entities/Chapter.php @@ -1,6 +1,8 @@ belongsTo(Book::class); - } - /** * Get the pages that this chapter contains. * @param string $dir @@ -42,10 +35,13 @@ class Chapter extends Entity public function getUrl($path = false) { $bookSlug = $this->getAttribute('bookSlug') ? $this->getAttribute('bookSlug') : $this->book->slug; + $fullPath = '/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug); + if ($path !== false) { - return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug) . '/' . trim($path, '/')); + $fullPath .= '/' . trim($path, '/'); } - return baseUrl('/books/' . urlencode($bookSlug) . '/chapter/' . urlencode($this->slug)); + + return url($fullPath); } /** @@ -56,7 +52,7 @@ class Chapter extends Entity public function getExcerpt(int $length = 100) { $description = $this->text ?? $this->description; - return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description; + return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description; } /**