api.go
changeset 231 741291bb4772
parent 207 301d5b94be3f
child 239 ca5639b4768e
equal deleted inserted replaced
230:d13e9a780d91 231:741291bb4772
    92 		urlp := url.Values{}
    92 		urlp := url.Values{}
    93 		for key, value := range request.QueryParams {
    93 		for key, value := range request.QueryParams {
    94 			// It seems Mastodon doesn't like parameters with index
    94 			// It seems Mastodon doesn't like parameters with index
    95 			// numbers, but it needs the brackets.
    95 			// numbers, but it needs the brackets.
    96 			// Let's check if the key matches '^.+\[.*\]$'
    96 			// Let's check if the key matches '^.+\[.*\]$'
       
    97 			// Do not proceed if there's another bracket pair.
    97 			klen := len(key)
    98 			klen := len(key)
    98 			if klen == 0 {
    99 			if klen == 0 {
    99 				continue
   100 				continue
   100 			}
   101 			}
   101 			i := strings.Index(key, "[")
   102 			i := strings.Index(key, "[")
   102 			if key[klen-1] == ']' && i > 0 {
   103 			if i > 0 && key[klen-1] == ']' && strings.Index(key[i+1:], "[") < 0 {
   103 				// This is an array, let's remove the index number
   104 				// This is an array, let's remove the index number
   104 				key = key[:i] + "[]"
   105 				key = key[:i] + "[]"
   105 			}
   106 			}
   106 			urlp.Add(key, value)
   107 			urlp.Add(key, value)
   107 		}
   108 		}