Escape vault name

This commit is contained in:
Andras Schmelczer 2025-12-02 21:36:04 +00:00
commit 8ef2f8c132

View file

@ -78,8 +78,8 @@ export class SyncService {
const result: SerializedError | DocumentVersionWithoutContent = const result: SerializedError | DocumentVersionWithoutContent =
(await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
| SerializedError | SerializedError
| DocumentVersionWithoutContent; | DocumentVersionWithoutContent;
if ("errorType" in result) { if ("errorType" in result) {
throw new Error( throw new Error(
@ -88,8 +88,7 @@ export class SyncService {
} }
this.logger.debug( this.logger.debug(
`Created document ${JSON.stringify(result)} with id ${ `Created document ${JSON.stringify(result)} with id ${result.documentId
result.documentId
}` }`
); );
@ -130,8 +129,8 @@ export class SyncService {
const result: SerializedError | DocumentUpdateResponse = const result: SerializedError | DocumentUpdateResponse =
(await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
| SerializedError | SerializedError
| DocumentUpdateResponse; | DocumentUpdateResponse;
if ("errorType" in result) { if ("errorType" in result) {
throw new Error( throw new Error(
@ -140,8 +139,7 @@ export class SyncService {
} }
this.logger.debug( this.logger.debug(
`Updated document ${JSON.stringify(result)} with id ${ `Updated document ${JSON.stringify(result)} with id ${result.documentId
result.documentId
}}` }}`
); );
@ -183,8 +181,8 @@ export class SyncService {
const result: SerializedError | DocumentUpdateResponse = const result: SerializedError | DocumentUpdateResponse =
(await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
| SerializedError | SerializedError
| DocumentUpdateResponse; | DocumentUpdateResponse;
if ("errorType" in result) { if ("errorType" in result) {
throw new Error( throw new Error(
@ -193,8 +191,7 @@ export class SyncService {
} }
this.logger.debug( this.logger.debug(
`Updated document ${JSON.stringify(result)} with id ${ `Updated document ${JSON.stringify(result)} with id ${result.documentId
result.documentId
}}` }}`
); );
@ -224,8 +221,8 @@ export class SyncService {
const result: SerializedError | DocumentVersionWithoutContent = const result: SerializedError | DocumentVersionWithoutContent =
(await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
| SerializedError | SerializedError
| DocumentVersionWithoutContent; | DocumentVersionWithoutContent;
if ("errorType" in result) { if ("errorType" in result) {
throw new Error( throw new Error(
@ -285,8 +282,8 @@ export class SyncService {
const result: SerializedError | FetchLatestDocumentsResponse = const result: SerializedError | FetchLatestDocumentsResponse =
(await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion (await response.json()) as // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
| SerializedError | SerializedError
| FetchLatestDocumentsResponse; | FetchLatestDocumentsResponse;
if ("errorType" in result) { if ("errorType" in result) {
throw new Error( throw new Error(
@ -325,7 +322,8 @@ export class SyncService {
private getUrl(path: string): string { private getUrl(path: string): string {
const { vaultName, remoteUri } = this.settings.getSettings(); const { vaultName, remoteUri } = this.settings.getSettings();
const remoteUriWithoutTrailingSlash = remoteUri.replace(/\/+$/, ""); const remoteUriWithoutTrailingSlash = remoteUri.replace(/\/+$/, "");
return `${remoteUriWithoutTrailingSlash}/vaults/${vaultName}${path}`; const encodedVaultName = encodeURIComponent(vaultName.trim());
return `${remoteUriWithoutTrailingSlash}/vaults/${encodedVaultName}${path}`;
} }
private getDefaultHeaders( private getDefaultHeaders(