-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite loop with special characters in kind names #6607
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-6128-fix-kind-sanitization-error.storybook.now.sh |
export const knownNonViewModesRegex = /(settings)/; | ||
const splitPath = /\/([^/]+)\/([^/]+)?/; | ||
const splitPathRegex = /\/([^/]+)\/([^/]+)?/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to something else given it has nothing to do with the splitPath
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmeasday Renamed the functions instead. LMK what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFM 👍
Codecov Report
@@ Coverage Diff @@
## next #6607 +/- ##
==========================================
- Coverage 40.67% 40.62% -0.05%
==========================================
Files 633 633
Lines 8674 8672 -2
Branches 620 621 +1
==========================================
- Hits 3528 3523 -5
- Misses 5057 5059 +2
- Partials 89 90 +1
Continue to review full report at Codecov.
|
lib/api/src/modules/stories.ts
Outdated
@@ -1,4 +1,5 @@ | |||
import { toId, sanitize } from '@storybook/router/dist/utils'; | |||
// FIXME: we shouldn't import from dist but there are no types otherwise | |||
import { toId, sanitize, parseKind } from '@storybook/router/dist/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shilman you can do:
import { toId, sanitize, parseKind } from '@storybook/router';
because index.ts
of @storybook/router
is exporting everything from /utils
folder:
export * from './utils';
export * from './router';
export const knownNonViewModesRegex = /(settings)/; | ||
const splitPath = /\/([^/]+)\/([^/]+)?/; | ||
const splitPathRegex = /\/([^/]+)\/([^/]+)?/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFM 👍
Issue: #6128
What I did
Detect when there are pathological kind names, e.g.
'Vue <docs/>'
where/
is a path separator and>
is a special character that gets filtered out from Story id's.Throw an error and warn the user rather then the "Maximum call stack error".
I also did a little refactoring.
How to test
Create a story in
official-storybook
:Before the change, this will mysteriously throw the Maximum call stack error. After, it will throw the error: