Forum Discussion

AlexDeMarco's avatar
AlexDeMarco
Icon for Nimbostratus rankNimbostratus
May 01, 2014

odd pathing issue

Here is a snippet of code:

 

set path1 [URI::path [HTTP::uri] 1 1] set path_len [string length $path1 ]

 

If I go to www.mysite.com in Firefox the path_len = 0 yet if I go via Chrome the length is 2.

 

Has anyone encountered this? How can I remove spaces from the variable so I get the tru length?

 

1 Reply

  • Perhaps the string trim command can help here:

    when HTTP_REQUEST {
        set path1 [string trim [URI::path [HTTP::uri] 1 1]] 
        set path_len [string length $path1]
    
        log local0. "uri = [HTTP::uri]"
        log local0. "path1 = $path1"
        log local0. "path_len = $path_len"
    }