CFLib.org – Common Function Library Project

FullQualUrl(mytext, relpage, FQHost)

Last updated November 2, 2001

author

Ryan Thompson-Jewell

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
Replace relative url's with a fully qualified URL within HREF tags. Handy for when you syndicating content to clients.

Return Values:
Returns a string.

Example:

<cfscript>
RelPage="index.cfm";
FQHost="http://www.yoursite.com";
// some text you want to parse
mytext="blah blah blah <a href=""index.cfm"">Home</a> blah blah blah ";
</cfscript>

<cfoutput>
Starting text:<br>
#mytext#<br>
<br>
<br>
Ending:<br>
#FullQualUrl(mytext,relpage,fqhost)#<br>
</cfoutput>

Parameters:

Name Description Required
mytext The string to search. Yes
relpage The page to qualify. Yes
FQHost The fully qualified host. Yes

Full UDF Source:

/**
 * Replace relative url's with a fully qualified URL
 * 
 * @param mytext 	 The string to search. 
 * @param relpage 	 The page to qualify. 
 * @param FQHost 	 The fully qualified host. 
 * @return Returns a string. 
 * @author Ryan Thompson-Jewell (thompsonjewell.ryan@mayo.edu) 
 * @version 1, November 2, 2001 
 */
function FullQualUrl(mytext,RelPage,FQHost) {
	var tmp=rereplacenocase(mytext,"(href\=){1}([""|'| ]*)(/)*(#RelPage#){1}","\1\2#FQHost#/#RelPage#","ALL");
	return tmp;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson