mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-04-23 13:08:11 +00:00
[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:
parent
d927629c19
commit
9d410496c0
1 changed files with 2 additions and 0 deletions
|
@ -3,6 +3,7 @@ const slugify = require("slugify");
|
||||||
const { Document } = require("./documents");
|
const { Document } = require("./documents");
|
||||||
const { WorkspaceUser } = require("./workspaceUsers");
|
const { WorkspaceUser } = require("./workspaceUsers");
|
||||||
const { ROLES } = require("../utils/middleware/multiUserProtected");
|
const { ROLES } = require("../utils/middleware/multiUserProtected");
|
||||||
|
const { v4: uuidv4 } = require("uuid");
|
||||||
|
|
||||||
const Workspace = {
|
const Workspace = {
|
||||||
writable: [
|
writable: [
|
||||||
|
@ -22,6 +23,7 @@ const Workspace = {
|
||||||
new: async function (name = null, creatorId = null) {
|
new: async function (name = null, creatorId = null) {
|
||||||
if (!name) return { result: null, message: "name cannot be null" };
|
if (!name) return { result: null, message: "name cannot be null" };
|
||||||
var slug = slugify(name, { lower: true });
|
var slug = slugify(name, { lower: true });
|
||||||
|
slug = slug || uuidv4();
|
||||||
|
|
||||||
const existingBySlug = await this.get({ slug });
|
const existingBySlug = await this.get({ slug });
|
||||||
if (existingBySlug !== null) {
|
if (existingBySlug !== null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue