diff --git a/shared/studio/state/connection.ts b/shared/studio/state/connection.ts index 18d34f13..dc10b3c5 100644 --- a/shared/studio/state/connection.ts +++ b/shared/studio/state/connection.ts @@ -91,7 +91,7 @@ export class Connection extends Model({ conn = AdminUIFetchConnection.create( { address: this.config.serverUrl, - database: this.config.database, + database: encodeURIComponent(this.config.database), user: this.config.user, token: this.config.authToken, }, diff --git a/shared/studio/tabs/ai/state/rag.ts b/shared/studio/tabs/ai/state/rag.ts index 9353405d..978a478e 100644 --- a/shared/studio/tabs/ai/state/rag.ts +++ b/shared/studio/tabs/ai/state/rag.ts @@ -64,7 +64,9 @@ export async function runRAGQuery( abortController: AbortController ): Promise { const response = await fetch( - `${connectConfig.serverUrl}/branch/${connectConfig.database}/ext/ai/rag`, + `${connectConfig.serverUrl}/branch/${encodeURIComponent( + connectConfig.database + )}/ext/ai/rag`, { method: "POST", headers: { diff --git a/shared/studio/tabs/auth/index.tsx b/shared/studio/tabs/auth/index.tsx index 9b6230e6..e30a54ae 100644 --- a/shared/studio/tabs/auth/index.tsx +++ b/shared/studio/tabs/auth/index.tsx @@ -145,7 +145,7 @@ const AuthUrls = observer(function AuthUrls({ if (url.hostname.endsWith(".edgedb.cloud")) { url.port = ""; } - url.pathname = `db/${databaseState.name}/ext/auth`; + url.pathname = `db/${encodeURIComponent(databaseState.name)}/ext/auth`; const baseUrl = url.toString(); diff --git a/shared/studio/tabs/dataview/index.tsx b/shared/studio/tabs/dataview/index.tsx index afe376a2..6032373f 100644 --- a/shared/studio/tabs/dataview/index.tsx +++ b/shared/studio/tabs/dataview/index.tsx @@ -53,7 +53,12 @@ export const DataView = observer(function DataView() { } else if (dbState.schemaData) { const updatedPath = state.updateFromPath(path ?? ""); if (updatedPath !== null) { - navigate(`${basePath}/${updatedPath}`, true); + navigate( + `${basePath}/${updatedPath + .map((part) => encodeURIComponent(part).replace(/%3A/g, ":")) + .join("/")}`, + true + ); } } }, [currentPath, dbState.schemaData]); diff --git a/shared/studio/tabs/dataview/state/index.ts b/shared/studio/tabs/dataview/state/index.ts index f8377e61..1837bbc4 100644 --- a/shared/studio/tabs/dataview/state/index.ts +++ b/shared/studio/tabs/dataview/state/index.ts @@ -118,9 +118,11 @@ export class DataView extends Model({ } @modelAction - updateFromPath(path: string): string | null { + updateFromPath(path: string): string[] | null { this.lastSelectedPath = path; - const [rootObjectTypeName, ...nestedParts] = path.split("/"); + const [rootObjectTypeName, ...nestedParts] = path + .split("/") + .map(decodeURIComponent); if (rootObjectTypeName !== this.inspectorStack[0]?.objectType?.name) { const objTypeId = this.objectTypes.find( (obj) => obj.name === rootObjectTypeName @@ -129,7 +131,7 @@ export class DataView extends Model({ this.selectObject(objTypeId); } else { this.selectObject(this.objectTypes[0]?.id); - return this.objectTypes[0]?.name ?? ""; + return [this.objectTypes[0]?.name ?? ""]; } } let i = 0; @@ -162,7 +164,7 @@ export class DataView extends Model({ (typeof objId === "number" && !this.edits.insertEdits.has(objId)) ) { this.inspectorStack = this.inspectorStack.slice(0, i + 1); - return [rootObjectTypeName, ...nestedParts.slice(0, i * 2)].join("/"); + return [rootObjectTypeName, ...nestedParts.slice(0, i * 2)]; } else { if ( objId !== stackItem?.parentObject!.id || diff --git a/shared/studio/tabs/repl/state/commands.ts b/shared/studio/tabs/repl/state/commands.ts index 83d25f03..4233c713 100644 --- a/shared/studio/tabs/repl/state/commands.ts +++ b/shared/studio/tabs/repl/state/commands.ts @@ -77,7 +77,7 @@ export async function handleSlashCommand( if (instanceState.databases!.includes(dbName)) { item.setCommandResult({kind: CommandOutputKind.none}); - repl.navigation?.(`${dbName}/repl`); + repl.navigation?.(`${encodeURIComponent(dbName)}/repl`); } else { item.setCommandResult({ kind: CommandOutputKind.error, diff --git a/web/src/components/databasePage/index.tsx b/web/src/components/databasePage/index.tsx index bfd42e10..757f1af7 100644 --- a/web/src/components/databasePage/index.tsx +++ b/web/src/components/databasePage/index.tsx @@ -101,7 +101,7 @@ function HeaderNavMenu({ label: db, selected: selectedDB === db, checked: currentDB === db, - linkProps: {to: `/${db}`}, + linkProps: {to: `/${encodeURIComponent(db)}`}, onHover: () => setSelectedDB(db), })) ?? null, }, @@ -113,7 +113,9 @@ function HeaderNavMenu({ navigate(`/${dbName}`)} + navigateToDB={(dbName) => + navigate(`/${encodeURIComponent(dbName)}`) + } /> ), }} diff --git a/web/src/components/instancePage/index.tsx b/web/src/components/instancePage/index.tsx index 598182e4..3f291749 100644 --- a/web/src/components/instancePage/index.tsx +++ b/web/src/components/instancePage/index.tsx @@ -21,7 +21,11 @@ export default observer(function InstancePage() {
{instanceState.instanceName}
{instanceState.databases?.map((db) => ( - + {db} @@ -59,7 +63,7 @@ export default observer(function InstancePage() { { - navigate(`/${branchName}`); + navigate(`/${encodeURIComponent(branchName)}`); }} /> );