2

I want to display URLs within a limited area: 2 lines and width of ~120px. Obviously most URLs don't fit.

So I'm looking for an approach to 'minify' an URL in order to make it smaller yet still recognizable and distinguishable from others.

for example:

https://stackoverflow.com/questions/ask

http://www.cnn.com/2011/US/03/04/obama.miami.school/index.html

http://techcrunch.com/2011/03/04/founder-stories-foursquare-crowley-invent-future/

http://cran.r-project.org/web/packages/bcp/index.html

become

stackoverflow | ask

cnn | obama.miami.school

techcrunch | founder-stories-foursquare

cran.r-project.org | packages/bcp

So you see this is kind of a creative question. Computing could either be done on server (Java) or client (Javascript).

Any feedback very welcome!

1
  • I think you can mostly go with regular expressions. But I see for some popular sites you remove the suffix, so it means you also need a database of popular sites (together with regex) Commented Mar 4, 2011 at 16:53

2 Answers 2

2

You can:

  • strip common parts ("http://", "www", ".com", ".html" ...)
  • strip numbers
  • strip multiple continous special characters (not letters)
  • define abrevations for common long parts (foursquare -> 4sq)

  • check the pieces that are left against a database how common they are. Keep the ones uncommon and drop the common ones until the result is short enough.

Sign up to request clarification or add additional context in comments.

Comments

2

I would be careful not remove to much information. Or create to much abbreviations.

You don't want

yourbank.com\login
yourbank.hackersite\login.php

both to look like:

yourbank | login

Or you are going to make it very easy for malicious people to abuse your system.

And even when you don't omit the top level domain part users can be easily confused, which malicious attackers might abuse. Perhaps highlighting the most important parts of the URL would be a improvement.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.