Created
December 16, 2015 23:40
-
-
Save tommyh/d59b926af789763d9b0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fakeWindow = {}; | |
for(var key in window) { | |
if(key !== "location"){ | |
fakeWindow[key] = window[key]; | |
} | |
} | |
var fakeLocation = {}; | |
for(var key in window.location) { | |
fakeLocation[key] = window.location[key]; | |
} | |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; // PUT the fake url here | |
fakeLocation.protocol = parser.protocol; | |
fakeLocation.hostname = parser.hostname; | |
fakeLocation.port = parser.port; | |
fakeLocation.pathname = parser.pathname; | |
fakeLocation.search = parser.search; | |
fakeLocation.hash = parser.hash; | |
fakeLocation.host = parser.host; | |
fakeLocation.href = parser.href; | |
fakeLocation.origin = parser.origin; | |
fakeWindow.location = fakeLocation; | |
(function(window){ | |
debugger; | |
})(fakeWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment