mirror of
https://github.com/discourse/discourse.git
synced 2025-02-14 15:24:57 +00:00
* DEV: Rnemae channel path to just c Also swap the channel id and channel slug params to be consistent with core. * linting * channel_path * params in wrong order * Drop slugify helper and channel route without slug * Request slug and route models through the channel model if possible * Add client side redirection for backwards-compatibility Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
25 lines
496 B
JavaScript
25 lines
496 B
JavaScript
import { slugify } from "discourse/lib/utilities";
|
|
|
|
export default function slugifyChannel(channel) {
|
|
if (channel.slug) {
|
|
return channel.slug;
|
|
}
|
|
|
|
if (!channel.escapedTitle && !channel.title) {
|
|
return "-";
|
|
}
|
|
|
|
const slug = slugify(channel.escapedTitle || channel.title);
|
|
const resolvedSlug = (
|
|
slug.length
|
|
? slug
|
|
: channel.title.trim().toLowerCase().replace(/\s|_+/g, "-")
|
|
).slice(0, 100);
|
|
|
|
if (!resolvedSlug) {
|
|
return "-";
|
|
}
|
|
|
|
return resolvedSlug;
|
|
}
|