@@ -86,7 +86,7 @@ defmodule URI do
86
86
per `encode_www_form/1`. This is the format typically used by browsers on
87
87
query strings and form data. It encodes " " as "+".
88
88
89
- * `:rfc_3986 ` - (since v1.12.0) the same as `:www_form` except it encodes
89
+ * `:rfc3986 ` - (since v1.12.0) the same as `:www_form` except it encodes
90
90
" " as "%20" according [RFC 3986](https://tools.ietf.org/html/rfc3986).
91
91
This is the best option if you are encoding in a non-browser situation,
92
92
since encoding spaces as "+" can be ambiguous to URI parsers. This can
@@ -105,14 +105,14 @@ defmodule URI do
105
105
"key=value+with+spaces"
106
106
107
107
iex> query = %{"key" => "value with spaces"}
108
- iex> URI.encode_query(query, :rfc_3986 )
108
+ iex> URI.encode_query(query, :rfc3986 )
109
109
"key=value%20with%20spaces"
110
110
111
111
iex> URI.encode_query(%{key: [:a, :list]})
112
112
** (ArgumentError) encode_query/2 values cannot be lists, got: [:a, :list]
113
113
114
114
"""
115
- @ spec encode_query ( Enum . t ( ) , :rfc_3986 | :www_form ) :: binary
115
+ @ spec encode_query ( Enum . t ( ) , :rfc3986 | :www_form ) :: binary
116
116
def encode_query ( enumerable , encoding \\ :www_form ) do
117
117
Enum . map_join ( enumerable , "&" , & encode_kv_pair ( & 1 , encoding ) )
118
118
end
@@ -125,7 +125,7 @@ defmodule URI do
125
125
raise ArgumentError , "encode_query/2 values cannot be lists, got: #{ inspect ( value ) } "
126
126
end
127
127
128
- defp encode_kv_pair ( { key , value } , :rfc_3986 ) do
128
+ defp encode_kv_pair ( { key , value } , :rfc3986 ) do
129
129
encode ( Kernel . to_string ( key ) , & char_unreserved? / 1 ) <>
130
130
"=" <> encode ( Kernel . to_string ( value ) , & char_unreserved? / 1 )
131
131
end
@@ -148,7 +148,7 @@ defmodule URI do
148
148
`decode_www_form/1`. This is the format typically used by browsers on
149
149
query strings and form data. It decodes "+" as " ".
150
150
151
- * `:rfc_3986 ` - (since v1.12.0) keys and values are decoded as per
151
+ * `:rfc3986 ` - (since v1.12.0) keys and values are decoded as per
152
152
`decode/1`. The result is the same as `:www_form` except for leaving "+"
153
153
as is in line with [RFC 3986](https://tools.ietf.org/html/rfc3986).
154
154
@@ -164,11 +164,11 @@ defmodule URI do
164
164
iex> URI.decode_query("percent=oh+yes%21", %{"starting" => "map"})
165
165
%{"percent" => "oh yes!", "starting" => "map"}
166
166
167
- iex> URI.decode_query("percent=oh+yes%21", %{}, :rfc_3986 )
167
+ iex> URI.decode_query("percent=oh+yes%21", %{}, :rfc3986 )
168
168
%{"percent" => "oh+yes!"}
169
169
170
170
"""
171
- @ spec decode_query ( binary , % { optional ( binary ) => binary } , :rfc_3986 | :www_form ) :: % {
171
+ @ spec decode_query ( binary , % { optional ( binary ) => binary } , :rfc3986 | :www_form ) :: % {
172
172
optional ( binary ) => binary
173
173
}
174
174
def decode_query ( query , map \\ % { } , encoding \\ :www_form )
@@ -227,7 +227,7 @@ defmodule URI do
227
227
`decode_www_form/1`. This is the format typically used by browsers on
228
228
query strings and form data. It decodes "+" as " ".
229
229
230
- * `:rfc_3986 ` - (since v1.12.0) keys and values are decoded as per
230
+ * `:rfc3986 ` - (since v1.12.0) keys and values are decoded as per
231
231
`decode/1`. The result is the same as `:www_form` except for leaving "+"
232
232
as is in line with [RFC 3986](https://tools.ietf.org/html/rfc3986).
233
233
@@ -241,11 +241,11 @@ defmodule URI do
241
241
iex> URI.query_decoder("food=bread%26butter&drinks=tap%20water+please") |> Enum.to_list()
242
242
[{"food", "bread&butter"}, {"drinks", "tap water please"}]
243
243
244
- iex> URI.query_decoder("food=bread%26butter&drinks=tap%20water+please", :rfc_3986 ) |> Enum.to_list()
244
+ iex> URI.query_decoder("food=bread%26butter&drinks=tap%20water+please", :rfc3986 ) |> Enum.to_list()
245
245
[{"food", "bread&butter"}, {"drinks", "tap water+please"}]
246
246
247
247
"""
248
- @ spec query_decoder ( binary , :rfc_3986 | :www_form ) :: Enumerable . t ( )
248
+ @ spec query_decoder ( binary , :rfc3986 | :www_form ) :: Enumerable . t ( )
249
249
def query_decoder ( query , encoding \\ :www_form ) when is_binary ( query ) do
250
250
Stream . unfold ( query , & decode_next_query_pair ( & 1 , encoding ) )
251
251
end
@@ -277,7 +277,7 @@ defmodule URI do
277
277
decode_www_form ( string )
278
278
end
279
279
280
- defp decode_with_encoding ( string , :rfc_3986 ) do
280
+ defp decode_with_encoding ( string , :rfc3986 ) do
281
281
decode ( string )
282
282
end
283
283
0 commit comments