diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/detail.handlers.ts index 1868dd7112..6bc74373bd 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/detail.handlers.ts @@ -12,7 +12,7 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: path, + Location: encodeURIComponent(path), }), ); }), @@ -20,14 +20,14 @@ export const detailHandlers = [ rest.get(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - const response = umbPartialViewMockDB.file.read(path); + const response = umbPartialViewMockDB.file.read(decodeURIComponent(path)); return res(ctx.status(200), ctx.json(response)); }), rest.delete(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - umbPartialViewMockDB.file.delete(path); + umbPartialViewMockDB.file.delete(decodeURIComponent(path)); return res(ctx.status(200)); }), @@ -36,7 +36,7 @@ export const detailHandlers = [ if (!path) return res(ctx.status(400)); const requestBody = (await req.json()) as UpdateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); - umbPartialViewMockDB.file.update(path, requestBody); + umbPartialViewMockDB.file.update(decodeURIComponent(path), requestBody); return res(ctx.status(200)); }), ]; diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/detail.handlers.ts index 06d4affa2e..4e7718e7ce 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/detail.handlers.ts @@ -12,7 +12,7 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: path, + Location: encodeURIComponent(path), }), ); }), @@ -20,14 +20,14 @@ export const detailHandlers = [ rest.get(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - const response = umbScriptMockDb.file.read(path); + const response = umbScriptMockDb.file.read(decodeURIComponent(path)); return res(ctx.status(200), ctx.json(response)); }), rest.delete(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - umbScriptMockDb.file.delete(path); + umbScriptMockDb.file.delete(decodeURIComponent(path)); return res(ctx.status(200)); }), @@ -36,7 +36,7 @@ export const detailHandlers = [ if (!path) return res(ctx.status(400)); const requestBody = (await req.json()) as UpdateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); - umbScriptMockDb.file.update(path, requestBody); + umbScriptMockDb.file.update(decodeURIComponent(path), requestBody); return res(ctx.status(200)); }), ]; diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/detail.handlers.ts index 2a5a0f249e..7611b9e53b 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/detail.handlers.ts @@ -12,7 +12,7 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: path, + Location: encodeURIComponent(path), }), ); }), @@ -20,14 +20,14 @@ export const detailHandlers = [ rest.get(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - const response = umbStylesheetData.file.read(path); + const response = umbStylesheetData.file.read(decodeURIComponent(path)); return res(ctx.status(200), ctx.json(response)); }), rest.delete(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => { const path = req.params.path as string; if (!path) return res(ctx.status(400)); - umbStylesheetData.file.delete(path); + umbStylesheetData.file.delete(decodeURIComponent(path)); return res(ctx.status(200)); }), @@ -36,7 +36,7 @@ export const detailHandlers = [ if (!path) return res(ctx.status(400)); const requestBody = (await req.json()) as UpdateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); - umbStylesheetData.file.update(path, requestBody); + umbStylesheetData.file.update(decodeURIComponent(path), requestBody); return res(ctx.status(200)); }), ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/partial-view-detail.server.data-source.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/partial-view-detail.server.data-source.ts index 336a866c7d..df1a900838 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/partial-view-detail.server.data-source.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/partial-view-detail.server.data-source.ts @@ -40,9 +40,7 @@ export class UmbPartialViewDetailServerDataSource implements UmbDetailDataSource // TODO: make data mapper to prevent errors const requestBody: CreatePartialViewRequestModel = { - parent: { - path: parentPath, - }, + parent: parentPath ? { path: parentPath } : null, name: appendFileExtensionIfNeeded(partialView.name, '.cshtml'), content: partialView.content, }; @@ -70,8 +68,12 @@ export class UmbPartialViewDetailServerDataSource implements UmbDetailDataSource if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Path is missing'); - const { data, error } = await tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewByPath({ path })); + const { data, error } = await tryExecuteAndNotify( + this.#host, + PartialViewResource.getPartialViewByPath({ path: encodeURIComponent(path) }), + ); if (error || !data) { return { error }; @@ -93,6 +95,7 @@ export class UmbPartialViewDetailServerDataSource implements UmbDetailDataSource if (!data.unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(data.unique); + if (!path) throw new Error('Path is missing'); const requestBody: UpdatePartialViewRequestModel = { content: data.content, @@ -101,7 +104,7 @@ export class UmbPartialViewDetailServerDataSource implements UmbDetailDataSource const { error } = await tryExecuteAndNotify( this.#host, PartialViewResource.putPartialViewByPath({ - path, + path: encodeURIComponent(path), requestBody, }), ); @@ -117,11 +120,12 @@ export class UmbPartialViewDetailServerDataSource implements UmbDetailDataSource if (!unique) throw new Error('Unique is missing'); const path = this.#serverPathUniqueSerializer.toServerPath(unique); + if (!path) throw new Error('Path is missing'); return tryExecuteAndNotify( this.#host, PartialViewResource.deletePartialViewByPath({ - path, + path: encodeURIComponent(path), }), ); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/repository/script-detail.server.data-source.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/repository/script-detail.server.data-source.ts index 2f4246a077..5ba5e212b1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/repository/script-detail.server.data-source.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/repository/script-detail.server.data-source.ts @@ -40,9 +40,7 @@ export class UmbScriptDetailServerDataSource implements UmbDetailDataSource