Escape vault name

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

View file

@ -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(