News for hackers. Stuff that matters.
Re:When is a URL shortener not a URL shortener? by jowiar on Tuesday August 16, 2011 @02:31AM (#2890126)
There are pigeonhole principle issues with the concept of url shortening - the same that apply to data compression in general.

With regards to urls that are a bit of ways down the tree (http://www.foo.com/bar/baz/whatever), this isn't really an issue, as generally within a domain, the url-friendliness comes at an expense of a great deal of length, and you can do something like:

shortened url := http://short.nr/shorten(domain)shorten(tail)

and end up with something shorter.

When trying to shorten already-short urls, though, characters will not necessarily be gained.

From Twitter's perspective, the ideal solution might be to count "urls" as a fixed length, or an attachment, with respect to the length of a tweet so as to sidestep this issue entirely.

Re:When is a URL shortener not a URL shortener? by philh on Tuesday August 16, 2011 @08:33AM (#2890883)
If all you want is shortening, then there shouldn't be a problem: if the t.co link is longer, just don't use it. This is different from data compression because "pointers are automatically dereferenced": there's no functional difference between t.co/foo sending you to google.com and t.co/bar sending you to t.co/foo. (If I'm wrong about this, then it's still possible to not-make-longer everything that isn't a t.co link.)

A similar case with data compression would be if you can guarantee that the decompressed data is never a valid compressed file. In this case, compress something iff that makes it shorter, and decompress something iff it's compressed.