"Did you mean this domain?" Auto-correction for the browser's address bar

05 April 2013   4 comments   Mozilla

Mind That Age!

This blog post is 4 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

People rarely type in long URLs. Therefore it's unlikely that one little typo in that long URL is the the deciding factor whether you get a 200 Found or a 404 Not Found.

However, what people often do is type in a domain name and hit enter. Sometimes they fumble and miss a character or accidentally add an additional one and ultimately land on this error:

One little typo and it looks like your Internet is down

Another thing I often do is I type the start of the domain name and fumble with the Awesome Bar and accidentally try to reach just the start of the domain. Like www.mozill for example.

The browser should in these cases be able to recognize the mistake and offer a nice "Did you mean this domain?" button or something that makes it one click to correct the innocent fumble.

How it could do this would be quite simple. It could record every domain you've visited based on your history. Then it could compute a an Edit distance and if it finds exactly one suggestion, offer it.

Here's how you can use an Edit distance algorithm:

>>> from edit_distance import EditDistance
>>> ed = EditDistance(('www.peterbe.com', 'www.mozilla.org', 'news.ycombinator.com',
...                    'twitter.com', 'www.facebook.com', 'github.com'))
>>> ed.match('www.peterbe.cm')
>>> ed.match('twittter.com')
>>> ed.match('www.faecbook.com')
>>> ed.match('github.comm')
>>> ed.match('neverheardof')

Here's the implementation I used.

Of course, this functionality should only kick in in the most desperate of cases. Ie. the URL can't resolve to anything. If someone is clever enough to buy the domain name facebok.com they deserve their traffic. And equally, if you type something like ww.peterbe.com or wwww.peterbe.com I've already set that up redirect to www.peterbe.com.

Here's what it could look like instead:
Here's what the improved error page could look like


Even better, 404s should to go to search instead. I never want to see a 404 when I'm using the location bar. The edit distance to local history trick would be a nice hack for those who want to minimize searches.
Alex Limi
Monica, they already do (unless you "search" for something that is actually parseable as a domain).
Peter Bengtsson
But these aren't 404s really. There's no apache that sends a 404 to make this error appear.

This message is what appears if you try query a DNS an get nothing useful back.
Right: so if you mistype d3js.org as d3.js, then it should fallback to search.
Thank you for posting a comment

Your email will never ever be published

Related posts

Never put external Javascript in the <head> 02 April 2013
Recruiters: if you're going to lie, do it properly 07 April 2013
EditDistanceMatcher - NodeJS script for doing edit distance 1 matching 05 February 2011
AJAX seach on 404 error pages 01 August 2005