Skip to content

Instantly share code, notes, and snippets.

@simonw simonw/gist:129240
Created Jun 13, 2009

Embed
What would you like to do?
<script type="text/javascript">
(function(loc) {
if (loc.pathname == '/') {
return;
}
var uri_re =
/^(?:(?:[^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/;
var target_domain = '';
loc.href.replace(uri_re, function(all, path, query, frag) {
var dst, src; dst = src = path + (query ? '?' + query : '');
if (frag) {
if (frag.charAt(0) == '/') {
dst = frag.replace(/^\/+/, '/').replace(
/_fb_qsub=([^&]+)&?/,
function(all, domain) {
if (
domain.substring(domain.length - 13) ==
'.facebook.com'
) {
target_domain = 'http://' + domain;
}
return '';
}
);
} else if (/&|=/.test(frag)) {
var q = {};
var m = frag.match(/([^#]*)(#.*)?/);
var arr =(query||'').split('&').concat((m[1]||'').split('&'));
for (var i = 0, length = arr.length; i < length; i++) {
var t = arr[i].split('=');
if (t.length && t[0] != '') {
q[t[0]] = t[1];
}
}
var s = [];
for (var i in q) {
s.push(i + (q[i] ? '=' + q[i] : ''));
}
dst = path + '?' + s.join('&') + (m[2] || '');
}
}
dst = "" + dst;
if (dst != src) {
window.location.replace(target_domain + dst);
}
});
})(window.location);
</script>
<script>
window.location.replace("http:\/\/www.facebook.com\/swillison");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.