Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const constructUrl = (storybookUrl, kind, story) => {
const id = toId(kind, story);
const storyUrl = `/iframe.html?id=${id}`;
const { protocol, host, pathname, search } = new URL(storybookUrl);
const pname = pathname.replace(/\/$/, ''); // removes trailing /
const query = search.replace('?', '&'); // convert leading ? to &
return `${protocol}//${host}${pname}${storyUrl}${query}`;
};
api.add = (storyName, storyFn, parameters) => {
hasAdded = true;
const { _globalParameters, _globalDecorators } = this;
const id = toId(kind, storyName);
if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}
if (m && m.hot && m.hot.dispose) {
m.hot.dispose(() => {
const { _storyStore } = this;
_storyStore.remove(id);
});
}
const fileName = m && m.id ? `${m.id}` : undefined;
const { hierarchyRootSeparator, hierarchySeparator } = this.getSeparators();
const baseOptions: OptionsParameter = {
hierarchyRootSeparator,
api.add = (storyName, storyFn, parameters) => {
hasAdded = true;
const { _globalParameters, _globalDecorators } = this;
const id = toId(kind, storyName);
if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}
if (m && m.hot && m.hot.dispose) {
m.hot.dispose(() => {
const { _storyStore } = this;
_storyStore.remove(id);
});
}
const fileName = m && m.id ? `${m.id}` : undefined;
const { hierarchyRootSeparator, hierarchySeparator } = this.getSeparators();
const baseOptions = {
hierarchyRootSeparator,
const createStoryQueryParameters = (kind, name) => `?id=${toId(kind, name)}`;
api.add = (storyName, storyFn, parameters) => {
hasAdded = true;
const { _globalParameters, _globalDecorators } = this;
const id = toId(kind, storyName);
if (typeof storyName !== 'string') {
throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);
}
if (m && m.hot && m.hot.dispose) {
m.hot.dispose(() => {
const { _storyStore } = this;
_storyStore.remove(id);
});
}
const fileName = m && m.id ? `${m.id}` : undefined;
const { hierarchyRootSeparator, hierarchySeparator } = this.getSeparators();
const baseOptions = {
hierarchyRootSeparator,