I have a CFC that returns a string containing part of a URL. I want to concatenate this to the end of the domain name of the site so it makes a fully qualified URL.
However, the ColdFusion is creating a space before the concatenation. Here is how my concatenation looks:
http://www.mywebsite.com#APPLICATION.MyCFC.GetURL(urlid = url.id)#
So we have two parts:
- The domain part which is just http://www.mywebsite.com
- The string that's returned from the CFC which is like this
/products/20
However the final output ends up like this:
http://www.mywebsite.com /products/20
So for some reason it puts a space just before concatenating the string from the CFC. I have tried to put a Trim()
around the CFC invokation but it doesn't do anything.
What I have also tried to do is put the string from the CFC in a variable like this <cfset myurl = #APPLICATION.MyCFC.GetURL(urlid = url.id)#
. I then concatenated this variable to the domain like this: http://www.mywebsite.com/#url#
and it works fine without adding any spaces.
Why is it doing this? I don't want to keep storing the output of the CFC in yet another local variable everytime I want to use it.
This is the code from the CFC (I've left out the database stuff that it does for sake of confidentially and clarity but its essentially just this):
<cffunction name="GetURL" access="public" returntype="string">
<cfargument name="urlid" required="yes">
<cfset var result="/products/#urlid#">
<cfreturn result>
</cffunction>