CFLib.org – Common Function Library Project

GetSecureURL([domain][, path][, queryString][, port])

Last updated May 10, 2009

author

Jon Hartmann

Version: 0 | Requires: CF5 | Library: StrLib

Description:
This function takes cgi information and creates a URL for an https to the current page. Each section can be overridden to allow it to create URLS for other locations.

Return Values:
Returns a string

Example:

<cfdump var="#GetSecureURL()#">

Parameters:

Name Description Required
domain url to secure No
path page to secure No
queryString queryString for page No
port additional port to use in url No

Full UDF Source:

<!---
 Creates an HTTPS URL for the current page, or for given page information.
 
 @param domain      url to secure (Optional)
 @param path      page to secure (Optional)
 @param queryString      queryString for page (Optional)
 @param port      additional port to use in url (Optional)
 @return Returns a string 
 @author Jon Hartmann (jon.hartmann@gmail.com) 
 @version 0, May 9, 2009 
--->
<cffunction name="GetSecureURL" output="false" returntype="string">
    <cfargument name="domain" typ="string" required="false" default="#cgi.server_name#" />
    <cfargument name="path" typ="string" required="false" default="#cgi.script_name#" />
    <cfargument name="queryString" typ="string" required="false" default="#cgi.query_string#" />
    <cfargument name="port" typ="string" required="false" default="#cgi.server_port#" />
    
    <cfset var HTTPSURL = "https://" & arguments.domain />
    
    <cfif IsNumeric(arguments.port)>
        <cfset HTTPSURL = HTTPSURL & ":" & arguments.port />
    </cfif>
    
    <cfset HTTPSURL = HTTPSURL & arguments.path />
    
    <cfif Len(arguments.queryString)>
        <cfset HTTPSURL = HTTPSURL & "?" & arguments.queryString />
    </cfif>
    
    <cfreturn HTTPSURL />
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson