diff --git a/lib/sinon/util/fake_server.js b/lib/sinon/util/fake_server.js index af6292a71..76b9d3fad 100644 --- a/lib/sinon/util/fake_server.js +++ b/lib/sinon/util/fake_server.js @@ -26,19 +26,21 @@ function getDefaultWindowLocation() { } function getWindowLocation() { - if ( typeof window !== "undefined") { - if (typeof window.location !== "undefined") { - // Browsers place location on window - return window.location; - } else if ((typeof window.window !== "undefined") && (typeof window.window.location !== "undefined")) { - // React Native on Android places location on window.window - return window.window.location; - } - + if (typeof window === "undefined") { + // Fallback return getDefaultWindowLocation(); } - // Fallback + if (typeof window.location !== "undefined") { + // Browsers place location on window + return window.location; + } + + if ((typeof window.window !== "undefined") && (typeof window.window.location !== "undefined")) { + // React Native on Android places location on window.window + return window.window.location; + } + return getDefaultWindowLocation(); }