Skip to content

Instantly share code, notes, and snippets.

@sota1235
Last active August 29, 2015 14:03
Show Gist options
  • Save sota1235/fa2a6d7f446c8459517d to your computer and use it in GitHub Desktop.
Save sota1235/fa2a6d7f446c8459517d to your computer and use it in GitHub Desktop.
function getRedirectPageUrl() {
var url = location.hash.substring(1);
console.log(url);
try {
if(url.length === 0) return "/";
url = decodeURIComponent(url);
if(!url.match(/^https?:\/\//)) return "/";
} catch(e) {
console.log("invalid url");
}
return url;
}
/* ... */
var url = getRedirectPageUrl();
console.log(url);
location.href = url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment