Running storycap with a URL that contains a query parameter fails to load, for example:
npx storycap http://localhost:6006\?theme\=dark
info Wait for connecting storybook server http://localhost:6006?theme=dark.
info Executable Chromium path: <redacted>
error waiting for function failed: timeout 60000ms exceeded
It appears to be due to storycrawler assuming the URL doesn't contain query string parameters, i.e.:
https://github.com/reg-viz/storycap/blob/master/packages/storycrawler/src/browser/stories-browser.ts#L70
Where it attempts to visit this.connection.url + '/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story', which in the above example would resolve to 'http://localhost:6006?theme=dark/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story'
Expected outcome
Query parameters are present when storycap loads each story.
Why?
It's possible to initialise Storybook globals using query string parameters. This is useful for capturing multiple themes without needing to re-build Storybook, for example.
How?
Split this.connection.url in to hostname and search. Use hostname as the base URL (this.connection.url) and merge search (query string params) in to the ones that storycrawler adds.
Running
storycapwith a URL that contains a query parameter fails to load, for example:It appears to be due to
storycrawlerassuming the URL doesn't contain query string parameters, i.e.:https://github.com/reg-viz/storycap/blob/master/packages/storycrawler/src/browser/stories-browser.ts#L70
Where it attempts to visit
this.connection.url + '/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story', which in the above example would resolve to'http://localhost:6006?theme=dark/iframe.html?selectedKind=story-crawler-kind&selectedStory=story-crawler-story'Expected outcome
Query parameters are present when
storycaploads each story.Why?
It's possible to initialise Storybook globals using query string parameters. This is useful for capturing multiple themes without needing to re-build Storybook, for example.
How?
Split
this.connection.urlin tohostnameandsearch. Usehostnameas the base URL (this.connection.url) and mergesearch(query string params) in to the ones thatstorycrawleradds.