Skip to content

Commit

Permalink
Restore queryparams exports from client-api
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Oct 20, 2021
1 parent 59059f9 commit 4511c90
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/client-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {

export * from './types';

export * from './queryparams';

// Typescript isn't happy that we are overwriting some types from store here
// @ts-ignore
export * from '@storybook/store';
Expand Down
18 changes: 18 additions & 0 deletions lib/client-api/src/queryparams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import global from 'global';
import { parse } from 'qs';

const { document } = global;

export const getQueryParams = () => {
// document.location is not defined in react-native
if (document && document.location && document.location.search) {
return parse(document.location.search, { ignoreQueryPrefix: true });
}
return {};
};

export const getQueryParam = (key: string) => {
const params = getQueryParams();

return params[key];
};

0 comments on commit 4511c90

Please sign in to comment.