From 0e0ec074623e6637a5ad2afe86acda49e2aa5e3b Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 18 Jan 2024 12:57:58 +0100 Subject: [PATCH] add new resource header + make the location header an absolute url --- .../src/mocks/handlers/data-type/detail.handlers.ts | 3 ++- .../src/mocks/handlers/data-type/folder.handlers.ts | 3 ++- .../src/mocks/handlers/document-type/detail.handlers.ts | 3 ++- .../src/mocks/handlers/media-type/detail.handlers.ts | 3 ++- .../src/mocks/handlers/media-type/folder.handlers.ts | 3 ++- .../src/mocks/handlers/partial-view/detail.handlers.ts | 4 +++- .../src/mocks/handlers/partial-view/folder.handlers.ts | 4 +++- .../src/mocks/handlers/partial-view/rename.handlers.ts | 4 +++- .../src/mocks/handlers/script/detail.handlers.ts | 4 +++- .../src/mocks/handlers/script/folder.handlers.ts | 4 +++- .../src/mocks/handlers/script/rename.handlers.ts | 4 +++- .../src/mocks/handlers/stylesheet/detail.handlers.ts | 5 ++++- .../src/mocks/handlers/stylesheet/folder.handlers.ts | 4 +++- .../src/mocks/handlers/stylesheet/rename.handlers.ts | 4 +++- .../src/mocks/handlers/user/invite.handlers.ts | 8 +++++++- 15 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/detail.handlers.ts index 8755fe49fe..733414055a 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/detail.handlers.ts @@ -14,7 +14,8 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: id, + Location: req.url.href + '/' + id, + 'Umb-Generated-Resource': id, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/folder.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/folder.handlers.ts index 2326b0a4fd..608446abab 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/folder.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/folder.handlers.ts @@ -13,7 +13,8 @@ export const folderHandlers = [ return res( ctx.status(201), ctx.set({ - Location: id, + Location: req.url.href + '/' + id, + 'Umb-Generated-Resource': id, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/document-type/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/document-type/detail.handlers.ts index fb9735ac11..ff7566750d 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/document-type/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/document-type/detail.handlers.ts @@ -14,7 +14,8 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: id, + Location: req.url.href + '/' + id, + 'Umb-Generated-Resource': id, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/detail.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/detail.handlers.ts index a7cfbffe5e..166ea0c421 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/detail.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/detail.handlers.ts @@ -14,7 +14,8 @@ export const detailHandlers = [ return res( ctx.status(201), ctx.set({ - Location: id, + Location: req.url.href + '/' + id, + 'Umb-Generated-Resource': id, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/folder.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/folder.handlers.ts index 3fcf4cd3de..6d666827d2 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/folder.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/folder.handlers.ts @@ -13,7 +13,8 @@ export const folderHandlers = [ return res( ctx.status(201), ctx.set({ - Location: id, + Location: req.url.href + '/' + id, + 'Umb-Generated-Resource': id, }), ); }), 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 6bc74373bd..b5448ef3f5 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 @@ -9,10 +9,12 @@ export const detailHandlers = [ const requestBody = (await req.json()) as CreateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbPartialViewMockDB.file.create(requestBody); + const encodedPath = encodeURIComponent(path); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/folder.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/folder.handlers.ts index 32c4e106bb..dba907337c 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/folder.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/folder.handlers.ts @@ -9,11 +9,13 @@ export const folderHandlers = [ const requestBody = (await req.json()) as CreatePartialViewFolderRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbPartialViewMockDB.folder.create(requestBody); + const encodedPath = encodeURIComponent(path); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/rename.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/rename.handlers.ts index 21d7bbc569..4057806d0d 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/rename.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/partial-view/rename.handlers.ts @@ -13,11 +13,13 @@ export const renameHandlers = [ if (!requestBody) return res(ctx.status(400, 'no body found')); const newPath = umbPartialViewMockDB.file.rename(decodeURIComponent(path), requestBody.name); + const encodedPath = encodeURIComponent(newPath); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(newPath), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), 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 4e7718e7ce..2059029bb2 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 @@ -9,10 +9,12 @@ export const detailHandlers = [ const requestBody = (await req.json()) as CreateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbScriptMockDb.file.create(requestBody); + const encodedPath = encodeURIComponent(path); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/folder.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/folder.handlers.ts index da2668695e..0a2de048fb 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/folder.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/folder.handlers.ts @@ -9,11 +9,13 @@ export const folderHandlers = [ const requestBody = (await req.json()) as CreateScriptFolderRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbScriptMockDb.folder.create(requestBody); + const encodedPath = encodeURIComponent(path); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/rename.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/rename.handlers.ts index 01cb62012e..a24018b14c 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/rename.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/script/rename.handlers.ts @@ -13,11 +13,13 @@ export const renameHandlers = [ if (!requestBody) return res(ctx.status(400, 'no body found')); const newPath = umbScriptMockDb.file.rename(decodeURIComponent(path), requestBody.name); + const encodedPath = encodeURIComponent(newPath); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(newPath), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), 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 a0d6f3b106..2e0750345a 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 @@ -9,10 +9,13 @@ export const detailHandlers = [ const requestBody = (await req.json()) as CreateStylesheetRequestModel; if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbStylesheetMockDb.file.create(requestBody); + const encodedPath = encodeURIComponent(path); + return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/folder.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/folder.handlers.ts index 6a92a201c5..b3b534633a 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/folder.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/folder.handlers.ts @@ -10,11 +10,13 @@ export const folderHandlers = [ if (!requestBody) return res(ctx.status(400, 'no body found')); const path = umbStylesheetMockDb.folder.create(requestBody); + const encodedPath = encodeURIComponent(path); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(path), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/rename.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/rename.handlers.ts index dce4556047..bbd2b85db5 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/rename.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/stylesheet/rename.handlers.ts @@ -13,11 +13,13 @@ export const renameHandlers = [ if (!requestBody) return res(ctx.status(400, 'no body found')); const newPath = umbStylesheetMockDb.file.rename(decodeURIComponent(path), requestBody.name); + const encodedPath = encodeURIComponent(newPath); return res( ctx.status(201), ctx.set({ - Location: encodeURIComponent(newPath), + Location: req.url.href + '/' + encodedPath, + 'Umb-Generated-Resource': encodedPath, }), ); }), diff --git a/src/Umbraco.Web.UI.Client/src/mocks/handlers/user/invite.handlers.ts b/src/Umbraco.Web.UI.Client/src/mocks/handlers/user/invite.handlers.ts index 42e8ba2b2c..d8b47e2b71 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/handlers/user/invite.handlers.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/handlers/user/invite.handlers.ts @@ -15,7 +15,13 @@ export const handlers = [ if (!userId) return res(ctx.status(400)); - return res(ctx.status(201), ctx.set('Location', userId)); + return res( + ctx.status(201), + ctx.set({ + Location: req.url.href + '/' + userId, + 'Umb-Generated-Resource': userId, + }), + ); }), rest.post(umbracoPath(`${inviteSlug}/resend`), async (req, res, ctx) => {