Broken shit
[semece.git] / lib / Semece / URI.pm
blobb42fbaf882be9a86313769b590e2ce5b9234b2b0
1 package Semece::URI;
2 # Copyright (c) 2010 Abel Abraham Camarillo Ojeda <acamari@verlet.org>
4 # Permission to use, copy, modify, and distribute this software for any
5 # purpose with or without fee is hereby granted, provided that the above
6 # copyright notice and this permission notice appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 # Get uri: Receives an URI has an argument, it returns the same URI but
18 # normalized, or return; if there is no argument. Currently the normalization
19 # process consists on making sure that all trailing slashes aren't duplicated.
20 sub
21 norm
23 my $uri = shift; # stores normalized uri
25 $Semece::debug->prntf("g_uri: da uri (%s)\n",
26 defined($uri) ? $uri : "") or
27 die "I couldn't prntf()!; $!; stopped";
28 return unless $uri;
30 $uri =~ s!/+!/!g; # normalization
32 return $uri;