From c068de8f704bce941eadc2e293dc2dd67d38a60a Mon Sep 17 00:00:00 2001 From: Len Kranendonk Date: Sat, 17 Jul 2004 20:35:47 +0000 Subject: [PATCH] Added makeAbsolute function --- lib/WebGUI/URL.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/WebGUI/URL.pm b/lib/WebGUI/URL.pm index a326aa12e..5e2e4a6d5 100644 --- a/lib/WebGUI/URL.pm +++ b/lib/WebGUI/URL.pm @@ -16,6 +16,7 @@ package WebGUI::URL; use strict; +use URI; use URI::Escape; use WebGUI::Session; use WebGUI::Utility; @@ -36,6 +37,7 @@ This package provides URL writing functionality. It is important that all WebGUI $string = WebGUI::URL::escape($string); $url = WebGUI::URL::gateway($url,$pairs); $url = WebGUI::URL::makeCompliant($string); + $url = WebGUI::URL::makeAbsolute($url); $url = WebGUI::URL::page($url,$pairs); $string = WebGUI::URL::unescape($string); $url = WebGUI::URL::urlize($string); @@ -158,6 +160,32 @@ sub gateway { return $url; } +#------------------------------------------------------------------- + +=head2 makeAbsolute ( url , [ baseURL ] ) + +Returns an absolute url. + +=over + +=item url + +The url to make absolute. + +=item baseURL + +The base URL to use. This defaults to current page url. + +=back + +=cut + +sub makeAbsolute { + my $url = shift; + my $baseURL = shift || page(); + return URI->new_abs($url,$baseURL); +} + #------------------------------------------------------------------- =head2 makeCompliant ( string )