[FIX]: Fix Chinese characters causing empty workspace slug (#660)

if slug is empty on create workspace, generate a uuid as the workspace slug
This commit is contained in:
Sean Hatfield 2024-01-31 13:38:21 -08:00 committed by GitHub
parent d927629c19
commit 9d410496c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ const slugify = require("slugify");
const { Document } = require("./documents");
const { WorkspaceUser } = require("./workspaceUsers");
const { ROLES } = require("../utils/middleware/multiUserProtected");
const { v4: uuidv4 } = require("uuid");
const Workspace = {
writable: [
@ -22,6 +23,7 @@ const Workspace = {
new: async function (name = null, creatorId = null) {
if (!name) return { result: null, message: "name cannot be null" };
var slug = slugify(name, { lower: true });
slug = slug || uuidv4();
const existingBySlug = await this.get({ slug });
if (existingBySlug !== null) {