Roman Rizzi d07b472b79
DEV: /channel -> /c chat route rename (#19782)
* 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>
2023-01-27 09:58:12 -03:00

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;
}