File: url_query.tcl

package info (click to toggle)
libapache2-mod-rivet 3.2.0-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 5,868 kB
  • sloc: xml: 8,496; tcl: 7,212; ansic: 6,959; sh: 5,030; makefile: 261; sql: 91; lisp: 78
file content (24 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -- url_query
#
# Build a URL query starting from a list of parameter-value
# pairs. If the list size is odd the last element in the list
# is discarded. Values in the list are escaped using 
# ::rivet::escape_string


namespace eval ::rivet {

    proc url_query {args} {

        set args_list $args

        set urlarg ""
        while {[llength $args_list] > 1} {
            set args_list [lassign $args_list par val]
            lappend urlarg "$par=[::rivet::escape_string $val]"
        }
        return [join $urlarg "&"]

    }

}