Friday, November 12, 2004

Adding a "www" option to Diggler

Someday I intend to create a list of tools I find essential to help me be more productive in a windows or linux environment. Until that day, I'll start small. Last summer, I wrote about Mozilla Firefox and its extensions. One extension I particularly like is Diggler. "It adds a menu button next to the address bar with actions relevant to the current URL, for example to step out to the parent directory..." and more. This means that if you're visiting:

Clicking on these will take your browser immediately to the new location.1 Another way to get a sense of what this extension does it by looking at a screenshot.

Now, what if you're looking at http://dir.yahoo.com or http://us.f604.mail.yahoo.com/ym/login?.rand=38fssok and you want to go to http://www.yahoo.com? Diggler's menu doesn't offer this as an option. But, diggler is customizable in a way that geeks will appreciate. The rest of you can tune out now. Using regular expressions, you can do pattern substitution to add this usage.2

Adding a "www" option to Diggler
Open the options for Diggler, add a new user defined tool. For the regular expression, enter:

^http://([a-zA-Z0-9-]+\.)+([a-zA-Z0-9-]+\.[a-zA-Z]+)(/.*)*$

for the action, enter

http://www.$2/

1I use Yahoo as an example because its directory's URLs are nicely hierarchical -- Yahoo also happens to provide clear links to go to each of these higher levels. Not every site is so friendly.2This won't work as expected with domains that have three significant chunks, e.g. with news.bbc.co.uk, you won't get www.bbc.co.uk, you'll get www.co.uk. Adding an additional tool to handle such URLs is left as an exercise for the reader