mirror of
https://github.com/flarum/framework.git
synced 2025-05-30 12:05:47 +08:00
No slug? Then no '-' separator! (#1351)
* Stop using slug separator when there is no slug * Changing as per upstream requirements
This commit is contained in:

committed by
Toby Zerner

parent
c3a6f7daef
commit
7721288ac6
@ -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
|
||||
});
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ export function slug(string) {
|
||||
return string.toLowerCase()
|
||||
.replace(/[^a-z0-9]/gi, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/-$|^-/g, '') || '-';
|
||||
.replace(/-$|^-/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user