http://www.ponyforweblinks.com July 20, 2010 6:13 PM   Subscribe

Is it possible to automatically prepend http:// in links in comments/posts when people fail to put them in?

Some portion of the time people (see this comment for an example) make links and fail to put in the http://. Since HTML is not smart enough to figure out that these are links to real webpages, they end up just being relative links back to the post, which are not particularly useful. I think it would be awesome if somewhere along the line there could be a check to see if a link has "http://" in front, and if not, just put it in. I get the impression that the number of actual relative links made in comments/posts approaches zero.
posted by that girl to Feature Requests at 6:13 PM (41 comments total)

The comment that you linked to, I just fixed. But basically it's something we've seen before, someone who puts www.example.com in the box w/o the http://

I don't know if a fix would be more of a hassle to code than us just going in and fixing these when we see them.
posted by jessamyn (staff) at 6:17 PM on July 20, 2010


If I find these sorts of comments (and pb decides that the coding is not worth it), would it be a reasonable idea to flag them with the HTML/display error flag?
posted by that girl at 6:25 PM on July 20, 2010


Yeah, this is something I've thought about – I think we should totally do this. The relative-link thing is probably responsible for 95% of the broken links on Metafilter, and I know it's annoyed me. I know mods just fix it themselves, but I'm pretty sure it can't be too hard (if you're already scraping comments for stuff like fake-comment-tails and stuff) and it'd be really swell not to ever post a link and then notice it's actually crap. This happens to me all the time, maybe because I'm absent-minded.
posted by koeselitz at 6:28 PM on July 20, 2010


I know pb has added code to clean up the opposite problem (the link box is pre-populated with "http://" and links would quite often end up looking like http://http://www.example.com), so there must already be a paddock for this new pony to graze in.
posted by flabdablet at 6:28 PM on July 20, 2010


Make A Working Link - No Typing Required
  • Open a new tab
  • Browse to your target page
  • Copy URL from address bar
  • Switch to MetaFilter tab
  • Highlight the text in your comment that you want to linkify
  • Click link button
  • Select the existing http:// text
  • Paste


  • Automagically fixing links missing the http prefix seems like a reasonable idea as well.
    posted by Babblesort at 6:32 PM on July 20, 2010


    There's also something in the HTML cleanup code that strips out links in some malformed code. Like when you forget a quote mark. I think that is what causes most of the "links back to the same page." I wonder if its worth adding logic to check for a blank href tag?
    posted by smackfu at 6:47 PM on July 20, 2010


    Making the magical code more difficult is you have to make sure you don't add it in front of other resource types (eg: mailto:, ftp:, gopher: etc.)
    posted by Mitheral at 6:58 PM on July 20, 2010


      Make A Working Link - Easy HTML Edition
    • Highlight and copy the URL that you would like to link to. Eg: "http://www.metafilter.com"
    • Type <a href="
    • Paste the URL into the HTML you've typed, close the quotes, and append a 'greater-than' symbol. Eg. <a href="http://www.metafilter.com">
    • Type the text you want to be a link. <a href="http://www.metafilter.com">MetaFilter
    • Close the anchor tag with </a>
    End result looks like this before posting: <a href="http://www.metafilter.com">MetaFilter</a>
    and this after you click 'Post Comment': MetaFilter
    posted by carsonb at 7:09 PM on July 20, 2010


    Ooh! Can we argue about this? We've been arguing about everything else recently!
    posted by slogger at 7:22 PM on July 20, 2010


    I just checked -- there already is a HTML-error flag.

    I figure only the mods would have any idea how much effort this is worth, but from this naive-user-viewpoint, this is an already solved problem. If anyone cares that teh link you miss-entered doesn't work, they can either FAMO, or they can send an email to the mods and it'll get fixed.

    [Now, if the mods ever get tired of being too awesome, they might ask about this pony..]

    On preview: Burhanistan's pony is (from my pov) both useful and adorable. But you knew that, right? Pretty obvious, now that I've pointed it out..


    posted by Tuesday After Lunch at 7:28 PM on July 20, 2010


    Ooh! Can we argue about this? We've been arguing about everything else recently!

    "I'd like to have an argument, please." (Monty Python's Argument Clinic)
    posted by Tuesday After Lunch at 7:35 PM on July 20, 2010


    I think this is one of the cases where the cure can end up worse than the disease. It's very easy to check for the presence of a specific string like http://http://. It's very rare that would come up outside of an HTML error, and it's easy to replace. Looking for the absence of a string and knowing that absence is a mistake is another problem altogether.

    The strength of HTML is that it's so flexible, you can write a link dozens of different ways:
    • <a href="http://www.metafilter.com/">MeFi</a>
    • <a target="_blank" href="http://www.metafilter.com/">MeFi</a>
    • <a href='http://www.metafilter.com/'>MeFi</a>
    • <a title="MetaFilter" href="http://www.metafilter.com/">MeFi</a>
    • <ahref="http://www.metafilter.com/">MeFi</a>
    And these are all perfectly valid and work equally well. That makes it difficult to come up with a blanket rule that will handle a missing "http://". And what if someone is demonstrating HTML? There are some cases where people write href="[not http://]..." and it's not a mistake.

    I think the existing flag it and we'll fix it method works fine. I agree that broken links are annoying, but breaking comments trying to fix broken links automatically could be worse.
    posted by pb (staff) at 8:00 PM on July 20, 2010 [1 favorite]


    That last one in the list is a typo and not valid at all. Flagged!
    posted by pb (staff) at 8:04 PM on July 20, 2010


    I pretty much agree with pb; a true fix for this would require more subtlety to implement in a way that was significantly more idiotproof than what we have now, and in the mean time we don't see a ton of this and can fix the ones that occur pretty easily if folks flag em.
    posted by cortex (staff) at 8:16 PM on July 20, 2010


    pb: “There are some cases where people write href="[not http://]..." and it's not a mistake.”

    Really? Not quibbling, just genuinely interested; do people really write relative links, or what?

    Guess I didn't realize anybody did that – if that's the case, then there's no point in scripting a fix. Makes sense.
    posted by koeselitz at 8:53 PM on July 20, 2010


    So, a quick, easy way to solve this for the majority of cases would be to check the first few characters returned by the Link button, and if it's not http:// then add it.

    Yeah, very true. If someone is using the link button we know they intend to add a link so that would be a better place to intervene. I was thinking about scanning the entire text once it's composed.
    posted by pb (staff) at 9:00 PM on July 20, 2010


    Is there any way to get the 'http://' that's included in the pop-up to not be selected? To just have the cursor blink at the end of it so if someone just starts typing 'www.metafetc' the http:// doesn't get deleted? Seems like that's a probable cause for the issue, when people see the http:// already there and just start typing the rest of the URL.
    posted by carsonb at 9:01 PM on July 20, 2010


    Okay then! Flagging it shall be! Somehow while making this post I had also forgotten about the HTML/display error flag, and on recalling it, went "Oh yeah, that."

    I suggest for a future April Fool's day thing that you make every link made in a comment redirect to random pictures of baby bunnies.
    posted by that girl at 9:02 PM on July 20, 2010


    And if that's possible and we're playing with focus/selection then can focus be added to the Username: field on the login page?
    posted by carsonb at 9:03 PM on July 20, 2010


    Nice idea carsonb, but we don't have control over what happens in a JavaScript input prompt. But we can send focus to the username field on login page load. Might mess with people who are used to hitting Tab on that page.
    posted by pb (staff) at 10:32 PM on July 20, 2010


    carsonb writes "Is there any way to get the 'http://' that's included in the pop-up to not be selected?"

    Please don't do this. If you are copy and pasting from an address bar you currently can just hit the link button and press CTRL+V Enter.
    posted by Mitheral at 10:35 PM on July 20, 2010


    Yeah, I don't use the link button at all myself, but I'm pretty sure the vast majority of people are copy-pasting from their address bar, so deselecting the "http://" would probably lead to a huge increase in errors (though those errors would be caught by the aforementioned check, I guess.) Sorry, carsonb, but that seems like an idea that would only help those who're typing in all their addys themselves, and somehow I doubt that many people are doing it like that.
    posted by koeselitz at 10:39 PM on July 20, 2010


    No skin off my teeth. I inhabit that damned purgatory called Just Enough Knowledge To Really Fuck Up when it comes to web stuff and, er, most things. MeFi-allowed HTML at speed is no problem and I could probably still pound out an early aughts-era homepage and stylesheet, but javascript? html5? everything else? —pretty much a mystery to me. Just spitballin' spaghetti to see if it sticks.

    pb - I'm coming around to the Tab key. That's a really old gripe of mine from before I discovered it's only one extra keystroke and stopped clicking into the field every time. Right around that same time I started logging in from a lot of different computers, so it's getting on into second nature by now. *shrug*
    posted by carsonb at 11:16 PM on July 20, 2010


    I was thinking about scanning the entire text once it's composed

    Catching ponies once they're out of the paddock is hard.
    posted by flabdablet at 11:36 PM on July 20, 2010


    While we're on the topic, I've been thinking that it would be nice if the link-ify button would trim() the selected text so that instead of:

  • blah blah blah

  • I would get:

  • blah blah blah

  • The difference is subtle. But double clicking a word in most webbrowsers seems to always highlight the trailing space.
    posted by jeffamaphone at 9:44 AM on July 21, 2010


    agreed jeffamaphone, that's one of my pet peeves too. I'll look at that too.
    posted by pb (staff) at 10:27 AM on July 21, 2010


    Hey, thanks pb.
    posted by jeffamaphone at 11:23 AM on July 21, 2010


    A few I've seen recently-

    https://
    news://
    finger://
    ftp://
    mailto:
    itms://

    And who could forget-

    gopher://


    IANA's list of URI schemes
    posted by jenkinsEar at 12:23 PM on July 21, 2010


    ok, just pushed out a new version of the link button. The new code adds http:// if those aren't the first characters of the URL. There's an exception for mailto:, webcal://, and the protocols jenkinsEar listed. (Thanks!) I figure if you're using one of the other URI schemes, you're probably not using the link button to write your HTML.

    Also, if the last character selected is a space it gets pushed outside the link. That should help trim up link text, and it's a very specific situation.

    I don't think these changes are too clever to break other uses of the link button, but if they are we can always go back to the way things were.

    If you'd like to test it, type something like "test text" into the comment form. Then highlight "test " (along with the space after it). Click the link button, enter "example.com", and you should end up with:

    <a href="http://example.com">test</a> text

    I tested it in Firefox, Chrome, Safari, IE6, and IE8. Let me know if you run into problems.
    posted by pb (staff) at 2:25 PM on July 21, 2010


    That last one in the list is a typo and not valid at all.

    Bummer. For a second there, I thought I learned an awesome new thing about making links.
    posted by box at 2:42 PM on July 21, 2010


    People probably don't post a lot of magnet URIs.
    posted by box at 2:45 PM on July 21, 2010


    nah, and if someone does need to use magnet:// they can write the link by hand. Or if that scheme takes off like wildfire and MeFi becomes a magnet link swapping hub we can just add it to the list of exceptions.
    posted by pb (staff) at 2:48 PM on July 21, 2010


    Woo, I got my pony!
    posted by that girl at 5:40 PM on July 21, 2010


    If anyone links to an iTunes URL directly, good luck to them.
    posted by smackfu at 5:45 PM on July 21, 2010


    I included the iTunes protocol—it was in jenkinsEar's list. So it should work.
    posted by pb (staff) at 6:06 PM on July 21, 2010


    Oh yeah, I saw it in the list. I meant actually using that would not go over well. Or really any of the more unusual ones.
    posted by smackfu at 6:16 PM on July 21, 2010


    I hear ya, but you never know. If there's a specific question related to the iTunes store it might make sense. I'm worried about being too inflexible because it's tough to predict what people will need. But I guess we'll see.
    posted by pb (staff) at 6:32 PM on July 21, 2010


    Even as we speak I am drafting my question about the best place to download a torrent of a Usenet client for the iPhone.
    posted by box at 7:14 PM on July 21, 2010


    Thanks pb, this is awesome. That trailing space thing drives me crazy but I figured it was just something that had to be endured.
    posted by Mitheral at 10:21 PM on July 21, 2010


    I got my pony too, and there was much rejoicing.

    YAAAY.
    posted by carsonb at 10:40 PM on July 21, 2010


    I didn't get a pony. Unsurprising, since I didn't ask (convenient link test: Ask/Guess).

    (I link using the example in the short tutorial, and have the extra http:// misfeature. So, I go back to the beginning and just backspace delete.)(this may be a test)

    so...

    Yep, (afaict) it meets or exceeds Airframe Mechanic (yat) standards, so yea/yaay!
    posted by Tuesday After Lunch at 7:06 PM on July 22, 2010


    « Older The Best Four Days in Meetups   |   Try harder. Newer »

    You are not logged in, either login or create an account to post comments