diff --git a/js/forum/src/initializers/routes.js b/js/forum/src/initializers/routes.js index c319b3d1a..0a2adc6f6 100644 --- a/js/forum/src/initializers/routes.js +++ b/js/forum/src/initializers/routes.js @@ -34,8 +34,9 @@ export default function(app) { * @return {String} */ app.route.discussion = (discussion, near) => { + const slug = discussion.slug(); return app.route(near && near !== 1 ? 'discussion.near' : 'discussion', { - id: discussion.id() + '-' + discussion.slug(), + id: discussion.id() + (slug.trim() ? '-' + slug : ''), near: near && near !== 1 ? near : undefined }); }; diff --git a/js/lib/utils/string.js b/js/lib/utils/string.js index 92ad98ae7..291e7bc7f 100644 --- a/js/lib/utils/string.js +++ b/js/lib/utils/string.js @@ -23,7 +23,7 @@ export function slug(string) { return string.toLowerCase() .replace(/[^a-z0-9]/gi, '-') .replace(/-+/g, '-') - .replace(/-$|^-/g, '') || '-'; + .replace(/-$|^-/g, ''); } /** diff --git a/src/Util/Str.php b/src/Util/Str.php index 258b8a75c..f8c7d6a67 100644 --- a/src/Util/Str.php +++ b/src/Util/Str.php @@ -28,6 +28,6 @@ class Str $str = preg_replace('/-+/', '-', $str); $str = preg_replace('/-$|^-/', '', $str); - return $str ?: '-'; + return $str; } } diff --git a/views/frontend/content/index.blade.php b/views/frontend/content/index.blade.php index 08a6cc492..d5c4040ab 100644 --- a/views/frontend/content/index.blade.php +++ b/views/frontend/content/index.blade.php @@ -7,7 +7,7 @@ @foreach ($document->data as $discussion)
  • {{ $discussion->attributes->title }}