Magneto,
Вариант...
var result,
pattern = /^https?:\/\/[^/]*(\/([^/?.]+|$))/;
result = 'http://google.com/webhp?....'.match( pattern );
alert( result && result[1] );
result = 'http://google.com/search?... '.match( pattern );
alert( result && result[1] );
result = 'http://google.com/#....'.match( pattern );
alert( result && result[1] );
result = 'http://google.com/'.match( pattern );
alert( result && result[1] );
result = 'http://google.com/...'.match( pattern );
alert( result && result[1] );
result = 'http://google.com/.../'.match( pattern );
alert( result && result[1] );
result = 'http://google.com'.match( pattern );
alert( result && result[1] );