URLParamSlice a shortcut of ctx.Request().URL.Query()[name]. Like `URLParam` but it returns all values instead of a single string separated by commas. Returns the values of a url query of the given "name" as string slice, e.g. ?names=john&names=doe&names=kataras and ?names=john,doe,kataras will retu
(name string)
| 1526 | // |
| 1527 | // See `URLParamsSorted` for sorted values. |
| 1528 | func (ctx *Context) URLParamSlice(name string) []string { |
| 1529 | values := ctx.getQuery()[name] |
| 1530 | n := len(values) |
| 1531 | if n == 0 { |
| 1532 | return values |
| 1533 | } |
| 1534 | |
| 1535 | var sep string |
| 1536 | if sepPtr := ctx.app.ConfigurationReadOnly().GetURLParamSeparator(); sepPtr != nil { |
| 1537 | sep = *sepPtr |
| 1538 | } |
| 1539 | |
| 1540 | normalizedValues := make([]string, 0, n) |
| 1541 | for _, v := range values { |
| 1542 | if v == "" { |
| 1543 | continue |
| 1544 | } |
| 1545 | |
| 1546 | if sep != "" { |
| 1547 | values := strings.Split(v, sep) |
| 1548 | normalizedValues = append(normalizedValues, values...) |
| 1549 | continue |
| 1550 | } |
| 1551 | |
| 1552 | normalizedValues = append(normalizedValues, v) |
| 1553 | } |
| 1554 | |
| 1555 | return normalizedValues |
| 1556 | } |
| 1557 | |
| 1558 | // URLParamTrim returns the url query parameter with trailing white spaces removed from a request. |
| 1559 | func (ctx *Context) URLParamTrim(name string) string { |
no test coverage detected