There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(server): add guid compatibility of :space:page variant (#5062)
liuyi9dc2d55a5a43
diff --git a/packages/backend/server/src/utils/__tests__/doc.spec.ts b/packages/backend/server/src/utils/__tests__/doc.spec.tsindex 328a76d83e..e39241f366 100644--- a/packages/backend/server/src/utils/__tests__/doc.spec.ts+++ b/packages/backend/server/src/utils/__tests__/doc.spec.ts@@ -70,3 +70,13 @@ test('fix', t => {t.is(id.workspace, 'ws');t.is(id.toString(), 'ws:space:sub');});++test('special case: `wsId:space:page:pageId`', t => {+ const id = new DocID('ws:space:page:page');+ t.is(id.workspace, 'ws');+ t.is(id.guid, 'page');++ t.throws(() => new DocID('ws:s:p:page'));+ t.throws(() => new DocID('ws:space:b:page'));+ t.throws(() => new DocID('ws:s:page:page'));+});diff --git a/packages/backend/server/src/utils/doc.ts b/packages/backend/server/src/utils/doc.tsindex 1754d280a6..7230b05a18 100644--- a/packages/backend/server/src/utils/doc.ts+++ b/packages/backend/server/src/utils/doc.ts@@ -55,7 +55,12 @@ export class DocID {let parts = raw.split(':');if (parts.length > 3) {- throw new Error(`Invalid format of Doc ID: ${raw}`);+ // special adapt case `wsId:space:page:pageId`+ if (parts[1] === DocVariant.Space && parts[2] === DocVariant.Page) {+ parts = [workspaceId ?? parts[0], DocVariant.Space, parts[3]];+ } else {+ throw new Error(`Invalid format of Doc ID: ${raw}`);+ }} else if (parts.length === 2) {// `${variant}:${guid}`if (!workspaceId) {