/**
  * Normalize each parameter by assuming each parameter may have already been
  * encoded, so attempt to decode, and then re-encode according to RFC 3986.
  *
  * Note both the key and value is normalized so a filter param like:
  *
  * 'filter[period]' => 'week'
  *
  * is encoded to:
  *
  * 'filter%5Bperiod%5D' => 'week'
  *
  * This conforms to the OAuth 1.0a spec which indicates the entire query string
  * should be URL encoded.
  *
  * @see rawurlencode()
  * @param array $parameters Un-normalized pararmeters.
  * @return array Normalized parameters.
  */
 private function normalize_parameters($parameters)
 {
     $keys = wc_rest_urlencode_rfc3986(array_keys($parameters));
     $values = wc_rest_urlencode_rfc3986(array_values($parameters));
     $parameters = array_combine($keys, $values);
     return $parameters;
 }
Esempio n. 2
0
 /**
  * Test wc_rest_urlencode_rfc3986().
  *
  * @since 2.6.0
  */
 public function test_wc_rest_urlencode_rfc3986()
 {
     $this->assertEquals('https%253A%252F%252Fwoocommerce.com%252F', wc_rest_urlencode_rfc3986('https://woocommerce.com/'));
 }