-15

Inspired by this meta-discussion, I felt the need to discuss a solution.

We could use a system whereby links that are arbitrarily too large would be automatically shortened using a service provided by Stack Overflow.

Short links could have a lifespan as long as a Stack Overflow post references it.

As an example...

You type out your question / answer. Click on the Hyperlink button to add the Hyperlink to your text.

After clicking Hyperlink

Get a message asking if you want to shorten the URL automatically.

After pasting in long URL

We agree. We now have a shortened URL hosted by Stack Overflow.

After agreeing to shorten the URL

15
  • Shortlinks are only remotely useful in comments. It seems unwieldy to have to use the answer field to generate a shortlink for use in a comment.
    – BoltClock Mod
    Commented Mar 29, 2016 at 14:58
  • 3
    How does a SO-hosted link-shortener benefit future users? SO carefully maintains the shortened link to something that no longer exists? Commented Mar 29, 2016 at 14:59
  • Very true. The system could easily be adapted for comments however. As for benefiting future users, that is an extremely valid point. One I cannot answer. That is of course, the problem with any external URL. However, if we are willing to post the full URLs as implied by Shog9: Please, just put the full URLs in the posts you're writing., that shouldn't be an issue.
    – Knossos
    Commented Mar 29, 2016 at 15:04
  • 5
    Consider that if one has the full URL and the link is dead, one can take that link to archive.org - this can't happen with a dead link shortener.
    – Oded StaffMod
    Commented Mar 29, 2016 at 15:08
  • 1
    @Oded: Since it would be hosted by StackOverflow, that should negate the dead link shortener issue?
    – Knossos
    Commented Mar 29, 2016 at 15:11
  • 4
    @Knossos - and if it fails? Or SO goes out of business? Then the data dump is full of short URLs that go nowhere.
    – Oded StaffMod
    Commented Mar 29, 2016 at 15:12
  • 1
    @Oded I would expect the data dump to contain the shortened and expanded pairs.
    – Knossos
    Commented Mar 29, 2016 at 15:16
  • 1
    @Oded: "and if it fails?" Twitter has the answer to that :)
    – BoltClock Mod
    Commented Mar 29, 2016 at 15:16
  • 8
    Link shorteners are a bad thing. This isn't new.
    – user229044 Mod
    Commented Mar 29, 2016 at 15:24
  • 1
    In all circumstances, even ones where the size of the URL could help to break the 30K limit on posts (as indicated in the Godbolt post)?
    – Knossos
    Commented Mar 29, 2016 at 15:29
  • 3
    @Knossos Yes. Shortened URLs are a bad thing, even in this case. If you want to use Gotbolt links in Stack Overflow, harass them to fix their service to generate usable links. It's not up to Stack Overflow to change and accommodate insane URL schemes.
    – user229044 Mod
    Commented Mar 29, 2016 at 15:32
  • If you were truly "incensed" (which means "enraged" or "very angry") about a meta-discussion, I would suggest taking a break from meta... Commented Mar 29, 2016 at 20:39
  • 2
    I do not wish for this feature. How do I know the destination link is not malicious if I cannot easily Google it. I tend to avoid clicking on shortened links if I feel the reward is trivial.
    – MonkeyZeus
    Commented Mar 29, 2016 at 21:25
  • @MikeMcCaughan Whoops. Looks like I need to read my dictionary a bit more.
    – Knossos
    Commented Mar 30, 2016 at 6:39
  • @meagar, Not unless they are goo.gl which is supported by a company that the world has confidence will outlast your original link, and at the same time doubling up as a auto spam removal. Besides, your comment reeks of Eurocentrism. goo.gl is widely used for the non-English Internet, especially so in textboxes and contexts that only support ASCII.
    – Pacerier
    Commented Apr 13, 2016 at 18:32

3 Answers 3

31

First off, Stack Overflow already has a URL shortening service: s.tk. It's mostly used internally and for ad campaigns, but it exists, we maintain it, and in rare cases it can be useful. Note that only a few people have access to create links using it, and that's probably not going to change for the reasons outlined in other answers and comments.

Second, Stack Overflow already offers short URLs for things like questions and answers: /q/[id] and /a/[id] are interchangeable and redirect handily to the question or answer associated with the ID. For internal links, this should be more than adequate: [this question](/q/319962) -> this question.

Finally, shorteners are completely unnecessary and actively harmful in ordinary Q&A. Links break frequently enough already; adding another layer of indirection just makes them harder to find and harder to fix, and adds yet another point of failure. You have 30,000 characters to play with here; that should be enough in most if not all circumstances. Let's face it: we don't have the markup structure to handle long articles in the way that (say) Wikipedia does; if your answer is exceeding 30,000 characters, you should probably break it up into multiple answers so that folks can find and link to the important bits. Or... y'know... learn to be slightly more concise. If I can fit my rambling into these constraints, I know you can.

That just leaves...

Comments

Comments are always problematic. In this case, the slim 600-character limit can potentially create a real hardship that simply doesn't exist for ordinary posts. It's not surprising then that folks have used URL shorteners in comments for a long time.

...But what have they been used for? I sat down last night, determined to find out.

First, I collected a list of shortened URLs from comments on Stack Overflow, comments that hadn't been deleted and weren't attached to deleted posts. I collected only URLs shortened via bit.ly, goo.gl, and tinyurl.com. Here's the list of 25K+ URLs, if you're interested.

Turns out the 30 most common short URLs were:

Ok, so this is mildly interesting... Primarily because none of those URLs are even long; heck, several are just links to questions on Stack Overflow, which (as I noted above) can be linked to using SO's own built-in short-form URLs. Several of them have some value as easy-to-remember URLs, but it's worth noting that two of those have been broken for a year and a half. Nick did a big search & replace back then on Jon's behalf, but of course these were obscured by the damn short URL... In theory, whoever created those short links could've updated them to point to the blog post, but... They didn't. So a thousand+ links that no one can edit are just sitting there, broken.

But enough about the top 30; they only account for about 50% of the short URLs used in comments, and as usual there's a long tail... I wonder how much is being obscured by these mostly-opaque URLs?

Since I had LINQPad open anyway, I decided to see if I could find out where all these links were pointing to:

// world's crappiest shorturl resolver
// don't do this at home, kids: find someone who knows what they're doing 
// and ask 'em to teach you about rate-limiting and backoff
foreach (String url in shortened)
{
    HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
    req.Method = "HEAD";
    req.AllowAutoRedirect = false;
    try
    {
        using (WebResponse resp = req.GetResponse())
        {
            var location = resp.Headers["Location"];
            var loc = "failed";
            if ( !string.IsNullOrEmpty(location) )
            {
                try
                {
                    loc = (new Uri(location)).Host;
                }
                catch (UriFormatException)
                {
                    loc = location;
                }
            }
            Console.WriteLine("{0}, {1}", url, loc);
        }
    }
    catch(WebException we)
    {
        Console.WriteLine("{0}, {1}", url, "failed");
    }
}   

A half hour or so later, I got some results to look at. Here are the top 30 hosts being directed to by those short URLs:

  • stackoverflow.com x2799
  • en.wikipedia.org x2230
  • php.net x2105
  • uk.php.net x1970
  • wiki.hashphp.org x1703
  • msmvps.com x1123
  • lmgtfy​.com x786
  • news.php.net x764
  • wiki.php.net x577
  • gcc.godbolt.org x521
  • github.com x497
  • failed x394
  • msdn.microsoft.com x271
  • meta.stackoverflow.com x249
  • developer.apple.com x222
  • codeblog.jonskeet.uk x202
  • www.google.com x166
  • www.tutorialspoint.com x142
  • developer.android.com x141
  • docs.google.com x141
  • www.dropbox.com x139
  • drive.google.com x137
  • code.google.com x129
  • blogs.msdn.com x93
  • groups.google.com x89
  • dl.dropbox.com x83
  • docs.oracle.com x81
  • gist.github.com x66
  • www.typescriptlang.org x65
  • www.lmgtfy​.com x64

Ok, so... This is kinda embarrassing. The most common use for URL shorteners in Stack Overflow comments is to point to posts on Stack Overflow. Rounding out the top three we have Wikipedia and php.net, neither of which are exactly famous for extremely long URLs. Seeing the long-banned LMGTFY in the top 10 isn't exactly a great feeling either. We do finally get to gcc.godbolt, a site that might legitimately have needed a shortener to be used in comments (though not anymore), at #10, two spots ahead of the not-quite-400 links that completely failed.

...About that... All those broken links to Skeet's blog were kinda bothering me. How many broken links are we hiding behind these short URLs?

I dropped the AllowAutoRedirect line from my crappy resolver above, and let it run while I went to bed and slept the good sleep of a decaying body in a broken world. And woke to yet another big list, which revealed that roughly 14% of these links are utterly broken. They'll likely never be fixed, most of them can't even be found, but there they sit. A little more grit in the machine.

In total, the compiler services identified by Ajedi32 in the other thread account for a hair over 3% of the total, with most of that being links to gcc.godbolt.org (which has a work-around in place now).

Final thoughts

The classic argument against blocking stuff like this is that folks will inevitably find a way around it. This is true. A blacklist is a rough tool, and no doubt some number of people will just pick a more obscure shortener and go on with what they were doing, our efforts to dissuade them wasted.

In spite of this, I cannot look at these results and not feel ashamed for waiting so long to implement this restriction. These links - and comments that depend on them - are a blight, and by failing to dissuade folks from their use (which we can now see was nearly always unwarranted even in comments), we've allowed them to take hold.

6
  • 1
    This appears to be the overall consensus. Thank you very much for your comprehensive answer.
    – Knossos
    Commented Mar 30, 2016 at 6:45
  • Hmm... perhaps s.tk could be opened up for public use, but only for whitelisted sites, or a general-user alternative could be provided? That would alleviate the problem of unwanted links, at the very least, by only shortening links from approved sites. To avoid dead links, it could periodically poll links, or something. Just an idea. Commented Oct 9, 2016 at 18:56
  • I have no desire to reduce things that can be linked to some whitelist of "approved" sites, @Justin. But it is nice to know, before clicking, what is being linked to. And that's an issue for any shortener, regardless of who operates it.
    – Shog9
    Commented Oct 10, 2016 at 18:01
  • Good point. This is a tough issue, if it isn't feasible to allocate more space in the comments database for links. A shortener that only works for a set of whitelisted sites would guarantee that any shortened URL, using that service, was to one of those sites (barring any exploits), but it would limit the use of helpful utilities that haven't been introduced to the staff. Conversely, a shortener that allows any site would allow utilities to be used without needing to first be approved & whitelisted, but just runs into the main "the link could be anything" problem. Commented Oct 10, 2016 at 19:33
  • The only "good" solution would be allowing more space in comments for links, but that seems like it would be a problem to implement, going by the discussions I've seen. Considering that, I'm not sure what the optimal solution is, but I figured letting general users approve verified sites would at least partially alleviate the issue. [Of course, if this were done, the people who are currently allowed to use s.tk would still be allowed to use it unrestricted, with the whitelist only applying to users that don't have that privilege.] Commented Oct 10, 2016 at 19:37
  • Realistically, the biggest use of shorteners in comments wasn't to save space, it was to save typing / make it easier to remember some common links. Which... Was nice. Until those links broke and couldn't be fixed.
    – Shog9
    Commented Oct 10, 2016 at 20:25
2

No.

4
  • Could you perhaps explain what you mean by your answer?
    – Knossos
    Commented Mar 29, 2016 at 15:24
  • @Knossos No. But look at the link.
    – user1228
    Commented Mar 29, 2016 at 15:25
  • 1
    It might help if you read the meta discussion I linked to. The issue is that an incredibly long link could make you run into the 30k limit. Godbolt has a "permalink" button which gives a goo.gl-shortened link to be copied-and-pasted. The unshortened links have all the compiler options, and the source code mime-encoded. All of that is urlencoded. I don't mind having links that are 1300 characters long for a 25 lines of code (with long comments), but it seems a bit excessive. It might make some of my answers run into the 30k char limit.
    – Knossos
    Commented Mar 29, 2016 at 15:28
  • 8
    @Knossos a character limit of 28700 characters is too short? Nah.
    – user1228
    Commented Mar 29, 2016 at 15:46
2

I think this could be a good idea if implemented correctly. The main problems with URL shorteners are:

  1. It's difficult for users to see where the URL ultimately points
  2. If the URL shortening service breaks, all links using it are broken
  3. It makes it difficult for Stack Overflow to filter out spam links and other undesirable URLs (like lmgtfy)
  4. In the rare situation where Stack Overflow wants to globally replace links to broken URLs with ones that work, shortened links are not updated

With a URL shortening service hosted by Stack Overflow though, all of these problems can be resolved in a rather straightforward manner:

  1. URLs can be expanded by Stack Overflow when the page is rendered, so users can easily see where the full URL leads by mousing over it
  2. Links will be a part of Stack Overflow, so they'll be around as long as Stack Overflow is
  3. Stack Overflow can simply refuse to shorten links to undesirable or spammy URLs
  4. Replacing links globally would actually be easier for SO-shortened URLs, just update the relevant column in the database

Additionally, we get the following benefits from allowing shortened URLs:

  1. Code compiler-type sites that use long URLs to store their code can once again be linked to in comments without going over the 600 character limit
1
  • 2
    This is essentially the Twitter strategy. Which is a pretty good one, if the utility of your software depends on fitting anything and everything into 140 characters. We don't really have that restriction though.
    – Shog9
    Commented Mar 30, 2016 at 0:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .