From 746448e57c789b5eaae879eb71a25b8fd8c07020 Mon Sep 17 00:00:00 2001 From: jang_yoonsu Date: Mon, 22 Apr 2024 23:13:01 +0900 Subject: [PATCH 1/2] Fix error message handling final slash in title --- code/lib/manager-api/src/lib/stories.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/code/lib/manager-api/src/lib/stories.ts b/code/lib/manager-api/src/lib/stories.ts index 9d6b1817e677..368edacc598a 100644 --- a/code/lib/manager-api/src/lib/stories.ts +++ b/code/lib/manager-api/src/lib/stories.ts @@ -194,13 +194,7 @@ export const transformStoryIndexToStoriesHash = ( const id = sanitize(parent ? `${parent}-${name}` : name!); if (parent === id) { - throw new Error( - dedent` - Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}' - - Did you create a path that uses the separator char accidentally, such as 'Vue ' where '/' is a separator char? See https://github.com/storybookjs/storybook/issues/6128 - ` - ); + throw new Error(dedent`Invalid title ${title} ending in slash.`); } list.push(id); return list; From 80144601f69d338f9b2df552de47916277bd98f9 Mon Sep 17 00:00:00 2001 From: jang_yoonsu Date: Sat, 4 May 2024 20:12:57 +0900 Subject: [PATCH 2/2] fix: clarify error messaging for title validation in path generation --- code/lib/manager-api/src/lib/stories.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/lib/manager-api/src/lib/stories.ts b/code/lib/manager-api/src/lib/stories.ts index 368edacc598a..3569cd29756e 100644 --- a/code/lib/manager-api/src/lib/stories.ts +++ b/code/lib/manager-api/src/lib/stories.ts @@ -193,9 +193,19 @@ export const transformStoryIndexToStoriesHash = ( const parent = idx > 0 && list[idx - 1]; const id = sanitize(parent ? `${parent}-${name}` : name!); - if (parent === id) { + if (name.trim() === '') { throw new Error(dedent`Invalid title ${title} ending in slash.`); } + + if (parent === id) { + throw new Error( + dedent` + Invalid part '${name}', leading to id === parentId ('${id}'), inside title '${title}' + + Did you create a path that uses the separator char accidentally, such as 'Vue ' where '/' is a separator char? See https://github.com/storybookjs/storybook/issues/6128 + ` + ); + } list.push(id); return list; }, [] as string[]);