Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created January 21, 2009 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotchpotch/49825 to your computer and use it in GitHub Desktop.
Save hotchpotch/49825 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>url max langth</title>
<script type="text/javascript">
(function() {
var urlLen = location.href.length;
location.hash.match(/l=(\d+)/);
var len;
if (len = RegExp.$1) {
len = len | 0;
if (len > 10000 * 100)
return alert('max length >= ' + len);
if (urlLen == len) {
len *= 2;
} else {
var l = (len / 2)|0;
len = l + ((l/4)|0);
if (len == urlLen) {
alert('max length = ' + len);
return;
}
}
} else {
len = 1000;
}
var url = location.href;
url = url.substr(0, url.indexOf(location.hash));
var q = '#l=' + len + '&';
var aLen = len - q.length - url.length;
var a = '';
for (var i = 0; i < aLen; i++) a+= 'a';
url += q + a;
location.href = url;
location.reload();
})();
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment