Skip to content

Commit 7781ad8

Browse files
benland3rd-Eden
authored andcommitted
[fix] global is not defined (#160)
* global is not defined #119 * better handling of global * Co-Authored-By: benland <[email protected]> * globalVar is always defined * Co-Authored-By: benland <[email protected]>
1 parent 9fb86cf commit 7781ad8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ var ignore = { hash: 1, query: 1 };
5353
* @public
5454
*/
5555
function lolcation(loc) {
56-
var location = global && global.location || {};
56+
var globalVar;
57+
58+
if (typeof window !== 'undefined')
59+
globalVar = window;
60+
else if (typeof global !== 'undefined')
61+
globalVar = global;
62+
else if (typeof self !== 'undefined')
63+
globalVar = self;
64+
else
65+
globalVar = {};
66+
var location = globalVar.location || {};
5767
loc = loc || location;
5868

5969
var finaldestination = {}

0 commit comments

Comments
 (0)