fix: URI encode datalake blob id and more workspace fixes (#6449)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-08-30 22:03:17 +07:00 committed by GitHub
parent 202adb5077
commit 15028992d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 8 additions and 8 deletions

View File

@ -21,7 +21,7 @@ import presentation from './plugin'
/** @public */
export function getCollaboratorClient (): CollaboratorClient {
const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.Workspace) ?? '')
const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.WorkspaceId) ?? '')
const token = getMetadata(presentation.metadata.Token) ?? ''
const collaboratorURL = getMetadata(presentation.metadata.CollaboratorUrl) ?? ''

View File

@ -184,7 +184,7 @@ function clearMetadata (ws: string): void {
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
const currentWorkspace = getMetadata(presentation.metadata.Workspace)
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId)
if (currentWorkspace !== undefined) {
setPresentationCookie('', currentWorkspace)
}

View File

@ -26,7 +26,7 @@ export class IndexeddbProvider extends IndexeddbPersistence implements Provider
readonly awareness: Awareness | null = null
constructor (documentId: string, doc: YDoc) {
const workspaceId: string = getMetadata(presentation.metadata.Workspace) ?? ''
const workspaceId: string = getMetadata(presentation.metadata.WorkspaceId) ?? ''
const name = `${workspaceId}/${documentId}`

View File

@ -31,7 +31,7 @@ import { IndexeddbProvider } from './indexeddb'
import { type Provider } from './types'
export function formatCollaborativeDocumentId (collaborativeDoc: CollaborativeDoc): DocumentId {
const workspace = getMetadata(presentation.metadata.Workspace) ?? ''
const workspace = getMetadata(presentation.metadata.WorkspaceId) ?? ''
return formatDocumentId(workspace, collaborativeDoc)
}

View File

@ -348,7 +348,7 @@ function clearMetadata (ws: string): void {
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
const currentWorkspace = getMetadata(presentation.metadata.Workspace)
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId)
if (currentWorkspace !== undefined) {
setPresentationCookie('', currentWorkspace)
}

View File

@ -46,7 +46,7 @@ export class AuthenticationExtension implements Extension {
const workspaceInfo = await getWorkspaceInfo(data.token)
// verify workspace url in the document matches the token
if (workspaceInfo.workspace !== workspaceId) {
if (workspaceInfo.workspaceId !== workspaceId) {
throw new Error('documentName must include workspace id')
}

View File

@ -49,7 +49,7 @@ export class Client {
constructor (private readonly endpoint: string) {}
getObjectUrl (ctx: MeasureContext, workspace: WorkspaceId, objectName: string): string {
const path = `/blob/${workspace.name}/${objectName}`
const path = `/blob/${workspace.name}/${encodeURIComponent(objectName)}`
return concatLink(this.endpoint, path)
}
@ -91,7 +91,7 @@ export class Client {
const form = new FormData()
const options: FormData.AppendOptions = {
filename: objectName,
filename: encodeURIComponent(objectName),
contentType: metadata.type,
knownLength: metadata.size,
header: {