parsing - How to parse the page name from a URL? -
i have url, , want final page name out of it. example, if url http://www.mysite.com/mypage.cfm
, want value mypage.cfm
. tried googling find if there built-in coldfusion functions can me accomplish this, haven't been able find any. so, did @ first implement sort of "endswith" function (which doesn't seem available in coldfusion either) - this:
<cfif right(cgi.http_referer, len("mypage.cfm")) eq "mypage.cfm"> ... whatever want if page "mypage.cfm" ...
this working well... problem if there's query string appended url won't work. example, if url http://www.mysite.com/mypage.cfm?param=whatever
, if statement evaluate false.
i can safely accomplish i'm trying checking if url contains page name using findnocase
... however, doesn't seem intuitive or correct. best way strip out page name url in coldfusion?
no built in functions per se, list functions should do:
<cfset pagename = listfirst(listlast(cgi.http_referer, '/'), '?')>
Comments
Post a Comment