Skip to content

Commit

Permalink
Flatten structure of getWindowLocation()
Browse files Browse the repository at this point in the history
  • Loading branch information
greena13 committed Apr 22, 2017
1 parent 77a360a commit 4fe0a73
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/sinon/util/fake_server.js
Expand Up @@ -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();
}

Expand Down

0 comments on commit 4fe0a73

Please sign in to comment.