-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add documentUrl
option
#12
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
@developit any updates? |
Hiya! Sorry about that - this looks great! |
src/index.js
Outdated
@@ -156,6 +156,10 @@ async function prerender (parentCompilation, request, options, inject, loader) { | |||
// suppress console-proxied eval() errors, but keep console proxying | |||
virtualConsole: new jsdom.VirtualConsole({ omitJSDOMErrors: false }).sendTo(console), | |||
|
|||
// `url` sets the value returned by `window.location`, `document.URL`... | |||
// Useful for routers that depend on the current URL (such as react-router or reach-router) | |||
url: options.documentUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we fall back to a default of http://localhost
here in order to fix #14?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently don't have internet, will change it once I get it fixed. Thanks for the review 😀
Some libraries such as
react-router
orreach-router
depend on the current window URL (returned bywindow.location
,location.URL
...) to determine which route to render.This PR adds a
documentUrl
option which is passed to the JSDOMurl
option which has the following behavior according to their docs:url
sets the value returned by window.location, document.URL, and document.documentURI, and affects things like resolution of relative URLs within the document and the same-origin restrictions and referrer used while fetching subresources. It defaults to "about:blank".The default value is
undefined
which will tell JSDOM to use the defaultabout:blank
which you cannot change inside the JSDOM instance.@developit