mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
fix(server): add guid compatibility of :space:page variant (#5062)
This commit is contained in:
@@ -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'));
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user