Skip to content
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

Set parse URL independent of browser window #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LeorentKelmendi
Copy link

Based on parse-url plugin:

Note that when url-parse is used in a browser environment, it will default to using the browser's current window location as the base URL when parsing all inputs. To parse an input independently of the browser's current URL (e.g. for functionality parity with the library in a Node environment), pass an empty location object as the second parameter:

var parse = require('url-parse');
parse('hostname', {});

when i tried to use the plugin with gatsby SSR failed due to url not being string as it could not extract window info causing Cannot read property 'split' of null to crash whole SSR.

passing second argument as {} solved the issue in SSR.

parse url independent of browser window to avoid crash in SSR, as current plugin breaks SSR due to default `window` use from `Url` parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant