From 2c048f8b90a1a1cc2c9b999dec68f34e58c81d1f Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Mon, 13 Jun 2022 17:46:01 +0200 Subject: [PATCH] Fix windows test and deprecated redirect method usage. Signed-off-by: Eric Peterson Co-authored-by: Emma Indal --- .changeset/techdocs-flying-inspection.md | 5 +++++ plugins/techdocs-node/src/stages/publish/local.test.ts | 3 ++- plugins/techdocs-node/src/stages/publish/local.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/techdocs-flying-inspection.md diff --git a/.changeset/techdocs-flying-inspection.md b/.changeset/techdocs-flying-inspection.md new file mode 100644 index 0000000000..baf956ee19 --- /dev/null +++ b/.changeset/techdocs-flying-inspection.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Updated deprecated use of `express`' `res.redirect()` method when handling legacy path casing. diff --git a/plugins/techdocs-node/src/stages/publish/local.test.ts b/plugins/techdocs-node/src/stages/publish/local.test.ts index daf943dce4..0119def16d 100644 --- a/plugins/techdocs-node/src/stages/publish/local.test.ts +++ b/plugins/techdocs-node/src/stages/publish/local.test.ts @@ -24,6 +24,7 @@ import request from 'supertest'; import mockFs from 'mock-fs'; import * as os from 'os'; import { LocalPublish } from './local'; +import path from 'path'; const createMockEntity = (annotations = {}, lowerCase = false) => { return { @@ -145,7 +146,7 @@ describe('local publisher', () => { ...{ kind: 'component', metadata: { - name: '../component/other-component', + name: path.join('..', 'component', 'other-component'), namespace: 'default', }, }, diff --git a/plugins/techdocs-node/src/stages/publish/local.ts b/plugins/techdocs-node/src/stages/publish/local.ts index c0de46eb22..11c6e6dd2b 100644 --- a/plugins/techdocs-node/src/stages/publish/local.ts +++ b/plugins/techdocs-node/src/stages/publish/local.ts @@ -220,7 +220,7 @@ export class LocalPublish implements PublisherBase { } // Otherwise, redirect to the new path. - return res.redirect(req.baseUrl + newPath, 301); + return res.redirect(301, req.baseUrl + newPath); }); router.use(