# Parsing a URI's base authority

**URL:** <https://www.ruby-forum.com/t/parsing-a-uris-base-authority/139083>\
**Category:** Ruby\
**Created:** [May 30, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/parsing-a-uris-base-authority/139083 "2008-05-30T17:21:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![and80](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@and80](https://www.ruby-forum.com/u/and80)\
**Post date:** [May 30, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/parsing-a-uris-base-authority/139083/1 "2008-05-30T17:21:25Z")

</div>

Hi all,  
I am looking for a ruby library to reliably determine the base  
authority of a URI host.

example:

[www.google.com](http://www.google.com) =\> [google.com](http://google.com)  
subdomain.domain.com.au =\> domain.com.au  
[www1.o2.co.uk](http://www1.o2.co.uk) =\> [02.co.uk](http://02.co.uk)  
blah.jp =\> blah.jp

here is a javascript based solution to this problem.  
[http://getoutfoxed.com/node/41](http://getoutfoxed.com/node/41)

Before trying to port this code in ruby, I was wandering if is there  
any already existing ruby gem or  
library designed to do this job…  
so far I have not been to solve this problem by simply using the uri  
parsing facilities included  
in the ruby standard library.

thank you in advance,  
Andrea
