# Uri-relative 0.0.1

**URL:** <https://www.ruby-forum.com/t/uri-relative-0-0-1/74935>\
**Category:** Ruby\
**Created:** [November 7, 2006, 11:03am UTC](https://www.ruby-forum.com/t/uri-relative-0-0-1/74935 "2006-11-07T11:03:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [November 7, 2006, 11:03am UTC](https://www.ruby-forum.com/t/uri-relative-0-0-1/74935/1 "2006-11-07T11:03:14Z")

</div>

So, okay, guys. I’m trying to get better about this release early/often  
thing.

Here is what I made today:

== WHAT IS IT?

uri-relative is a small gem which embellishes URI::Generic with a few  
useful methods: URI::Generic#normalize (and normalize!),  
URI::Generic#resolve, and URI::Generic#relativize.

- normalize compresses those /./ and /…/ bits in your paths

- resolve uses one URI as reference to convert another URI  
from relative to absolute (per RFC 2396)

- relativize will do the reverse, taking a URI from absolute  
to relative (per… Java-URI I guess)

Keen Java-ists may note a certain similarity to what’s offered by Java’s  
URI class. It’s not entirely accidental. But mainly I just needed to  
do some of that same sort of URI manipulation in Ruby and nobody could  
point me to any libraries to do it.

All pyramids look alike.

== IS IT DONE YET?

Well, I think the coding part is basically done. I just need to  
implement URI::Generic#relativize and write documentation.

== WHERE DO I GET IT?

I’ll have a rubyforge project set up sooner or later. Like, after I  
implement URI::Generic#relativize.

In the meantime, there is a tiny embittered stump of a website here:

[http://moonbase.rydia.net/software/uri-relative/](http://moonbase.rydia.net/software/uri-relative/)

But really I would only bother with the gem and/or tarball:

[http://moonbase.rydia.net/software/uri-relative/uri-relative-0.0.1.gem](http://moonbase.rydia.net/software/uri-relative/uri-relative-0.0.1.gem)

[http://moonbase.rydia.net/software/uri-relative/uri-relative-0.0.1.tgz](http://moonbase.rydia.net/software/uri-relative/uri-relative-0.0.1.tgz)

---

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/uri-relative-0-0-1/74935/2 "2006-11-07T11:04:26Z")

</div>

Hah! Well, I feel dumb. URI::Generic#merge and URI::Generic#route\_to  
do precisely the same thing as my own methods. And they’re the  
practically the only rdoc’d methods in URI::Generic, too. Should have  
stuck out like a sore thumb.

So … that leaves URI::Generic#normalize, I think. Anyone have a use  
for it?

-mental

---

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/uri-relative-0-0-1/74935/3 "2006-11-07T11:04:28Z")

</div>

Briefly, I’ve dropped my own resolution and relativization methods in  
favor of the existing ones in URI::Generic. So, uri-relative is now  
simply a library that adds a Java-esque ‘normalize’ method and some  
aliases to Ruby’s URI::Generic.

The project page (such as it is) is here:

[http://moonbase.rydia.net/software/uri-generic/](http://moonbase.rydia.net/software/uri-generic/)

Are there any other useful things which are actually missing? Or have I  
also missed some obvious way to do normalization with stock  
URI::Generic?

(By the way: here’s the funny part: I was actually calling  
URI::Generic#merge as part of my URI::Generic#resolve, without realizing  
its full functionality! I suppose that at least I can say that  
implementing my own resolve and relativize methods was a useful learning  
exercise…)

-mental
