Forum Discussion
Walter_WorkAcct
Mar 15, 2022Altostratus
Assistance with Concatenation
I am trying to use the following code to convert html links to those with PDFs as the target. The issue I have is with concatenation and the correct syntax. The code below gives a trailing close brac...
- Mar 16, 2022
You don't really need to use the concat command here, you can just order your strings inline like this:
HTTP::respond 301 Location "https://[HTTP::host]/archive/[string map -nocase {.html .pdf} [HTTP::uri]]"
You can also test this Tcl syntax with placeholders in the tcl shell:
% set host www.example.com www.example.com % set uri1 matching-uri.html matching-uri.html % set uri2 unmatching-uri.htm unmatching-uri.htm % set uri3 unmatching-uri.pdf unmatching-uri.pdf % puts “https://$host/archive/[string map -nocase {.html .pdf} $uri1]” “https://www.example.com/archive/matching-uri.pdf” % puts “https://$host/archive/[string map -nocase {.html .pdf} $uri2]” “https://www.example.com/archive/unmatching-uri.htm” % puts “https://$host/archive/[string map -nocase {.html .pdf} $uri3]” “https://www.example.com/archive/unmatching-uri.pdf”
JRahm
Mar 16, 2022Admin
You don't really need to use the concat command here, you can just order your strings inline like this:
HTTP::respond 301 Location "https://[HTTP::host]/archive/[string map -nocase {.html .pdf} [HTTP::uri]]"
You can also test this Tcl syntax with placeholders in the tcl shell:
% set host www.example.com
www.example.com
% set uri1 matching-uri.html
matching-uri.html
% set uri2 unmatching-uri.htm
unmatching-uri.htm
% set uri3 unmatching-uri.pdf
unmatching-uri.pdf
% puts “https://$host/archive/[string map -nocase {.html .pdf} $uri1]”
“https://www.example.com/archive/matching-uri.pdf”
% puts “https://$host/archive/[string map -nocase {.html .pdf} $uri2]”
“https://www.example.com/archive/unmatching-uri.htm”
% puts “https://$host/archive/[string map -nocase {.html .pdf} $uri3]”
“https://www.example.com/archive/unmatching-uri.pdf”
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects