Skip to content

Commit

Permalink
Wrap with try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Nov 23, 2021
1 parent 7fd1457 commit 696998b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/components/src/typography/DocumentFormatting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ export const Pre = styled.pre<{}>(withReset, withMargin, ({ theme }) => ({
const Link: FunctionComponent<any> = ({ href: input, children, ...props }) => {
// If storybook is hosted at a non-root path (e.g. `/storybook/`),
// the base url needs to be prefixed to storybook paths.
let storybookBaseUrl =
typeof window !== 'undefined' ? window.parent.document.location.pathname : '/';
let storybookBaseUrl = '/';
if (typeof window !== 'undefined') {
try {
storybookBaseUrl = window.parent.document.location.pathname;
} catch (error) {
// For composed storybooks this doesn't work due to a CORS error
}
}
if (!storybookBaseUrl.endsWith('/')) storybookBaseUrl += '/';

const isStorybookPath = /^\//.test(input);
Expand Down

0 comments on commit 696998b

Please sign in to comment.