From c017aeeb4e01b9ed48f163a1501c581173e2ab4e Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 17 Feb 2024 19:36:33 +0900 Subject: [PATCH 1/2] Storybook: Add mechanism to redirect moved stories --- .../src/radio-group/stories/index.story.tsx | 1 + storybook/manager-head.html | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 storybook/manager-head.html diff --git a/packages/components/src/radio-group/stories/index.story.tsx b/packages/components/src/radio-group/stories/index.story.tsx index cfa0a253fb7a0b..d9cf34c93b2ed1 100644 --- a/packages/components/src/radio-group/stories/index.story.tsx +++ b/packages/components/src/radio-group/stories/index.story.tsx @@ -16,6 +16,7 @@ import { useState } from '@wordpress/element'; const meta: Meta< typeof RadioGroup > = { title: 'Components (Deprecated)/RadioGroup', + id: 'components-radiogroup', component: RadioGroup, // @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170 subcomponents: { Radio }, diff --git a/storybook/manager-head.html b/storybook/manager-head.html new file mode 100644 index 00000000000000..c60559285738c1 --- /dev/null +++ b/storybook/manager-head.html @@ -0,0 +1,35 @@ + From 5725d9293a63ef420337c3bc70df8eef16130873 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 27 Feb 2024 01:54:59 +0900 Subject: [PATCH 2/2] Simplify URL construction --- storybook/manager-head.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/storybook/manager-head.html b/storybook/manager-head.html index c60559285738c1..21ee902c02a36d 100644 --- a/storybook/manager-head.html +++ b/storybook/manager-head.html @@ -24,11 +24,10 @@ .replace( matchedRedirect.from, matchedRedirect.to ) ); + const { pathname, origin } = window.location; + // The decodeURIComponent keeps the slashes intact, to match how Storybook presents the `path` param. const newUrl = - window.location.origin + - window.location.pathname + - '?' + - decodeURIComponent( params.toString() ); + new URL( pathname, origin ) + '?' + decodeURIComponent( params ); window.location.replace( newUrl ); } )();