From 8ef2f8c132089f82e621716ac483d770c65f2bfd Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 2 Dec 2025 21:36:04 +0000 Subject: [PATCH] Escape vault name --- .../sync-client/src/services/sync-service.ts | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/frontend/sync-client/src/services/sync-service.ts b/frontend/sync-client/src/services/sync-service.ts index ba047b5e..11c22207 100644 --- a/frontend/sync-client/src/services/sync-service.ts +++ b/frontend/sync-client/src/services/sync-service.ts @@ -78,8 +78,8 @@ export class SyncService { const result: SerializedError | DocumentVersionWithoutContent = (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion - | SerializedError - | DocumentVersionWithoutContent; + | SerializedError + | DocumentVersionWithoutContent; if ("errorType" in result) { throw new Error( @@ -88,8 +88,7 @@ export class SyncService { } this.logger.debug( - `Created document ${JSON.stringify(result)} with id ${ - result.documentId + `Created document ${JSON.stringify(result)} with id ${result.documentId }` ); @@ -130,8 +129,8 @@ export class SyncService { const result: SerializedError | DocumentUpdateResponse = (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion - | SerializedError - | DocumentUpdateResponse; + | SerializedError + | DocumentUpdateResponse; if ("errorType" in result) { throw new Error( @@ -140,8 +139,7 @@ export class SyncService { } this.logger.debug( - `Updated document ${JSON.stringify(result)} with id ${ - result.documentId + `Updated document ${JSON.stringify(result)} with id ${result.documentId }}` ); @@ -183,8 +181,8 @@ export class SyncService { const result: SerializedError | DocumentUpdateResponse = (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion - | SerializedError - | DocumentUpdateResponse; + | SerializedError + | DocumentUpdateResponse; if ("errorType" in result) { throw new Error( @@ -193,8 +191,7 @@ export class SyncService { } this.logger.debug( - `Updated document ${JSON.stringify(result)} with id ${ - result.documentId + `Updated document ${JSON.stringify(result)} with id ${result.documentId }}` ); @@ -224,8 +221,8 @@ export class SyncService { const result: SerializedError | DocumentVersionWithoutContent = (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion - | SerializedError - | DocumentVersionWithoutContent; + | SerializedError + | DocumentVersionWithoutContent; if ("errorType" in result) { throw new Error( @@ -285,8 +282,8 @@ export class SyncService { const result: SerializedError | FetchLatestDocumentsResponse = (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion - | SerializedError - | FetchLatestDocumentsResponse; + | SerializedError + | FetchLatestDocumentsResponse; if ("errorType" in result) { throw new Error( @@ -325,7 +322,8 @@ export class SyncService { private getUrl(path: string): string { const { vaultName, remoteUri } = this.settings.getSettings(); const remoteUriWithoutTrailingSlash = remoteUri.replace(/\/+$/, ""); - return `${remoteUriWithoutTrailingSlash}/vaults/${vaultName}${path}`; + const encodedVaultName = encodeURIComponent(vaultName.trim()); + return `${remoteUriWithoutTrailingSlash}/vaults/${encodedVaultName}${path}`; } private getDefaultHeaders(