@@ -6,23 +6,23 @@ use regex::{Captures, Regex};
6
6
use serde_json:: value:: { to_value, Value } ;
7
7
use unic_segment:: GraphemeIndices ;
8
8
9
- #[ cfg( feature = "builtins " ) ]
9
+ #[ cfg( feature = "urlencode " ) ]
10
10
use percent_encoding:: { percent_encode, AsciiSet , NON_ALPHANUMERIC } ;
11
11
12
12
use crate :: errors:: { Error , Result } ;
13
13
use crate :: utils;
14
14
15
15
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
16
- #[ cfg( feature = "builtins " ) ]
16
+ #[ cfg( feature = "urlencode " ) ]
17
17
const FRAGMENT_ENCODE_SET : & AsciiSet =
18
18
& percent_encoding:: CONTROLS . add ( b' ' ) . add ( b'"' ) . add ( b'<' ) . add ( b'>' ) . add ( b'`' ) ;
19
19
20
20
/// https://url.spec.whatwg.org/#path-percent-encode-set
21
- #[ cfg( feature = "builtins " ) ]
21
+ #[ cfg( feature = "urlencode " ) ]
22
22
const PATH_ENCODE_SET : & AsciiSet = & FRAGMENT_ENCODE_SET . add ( b'#' ) . add ( b'?' ) . add ( b'{' ) . add ( b'}' ) ;
23
23
24
24
/// https://url.spec.whatwg.org/#userinfo-percent-encode-set
25
- #[ cfg( feature = "builtins " ) ]
25
+ #[ cfg( feature = "urlencode " ) ]
26
26
const USERINFO_ENCODE_SET : & AsciiSet = & PATH_ENCODE_SET
27
27
. add ( b'/' )
28
28
. add ( b':' )
@@ -38,7 +38,7 @@ const USERINFO_ENCODE_SET: &AsciiSet = &PATH_ENCODE_SET
38
38
/// Same as Python quote
39
39
/// https://github.com/python/cpython/blob/da27d9b9dc44913ffee8f28d9638985eaaa03755/Lib/urllib/parse.py#L787
40
40
/// with `/` not escaped
41
- #[ cfg( feature = "builtins " ) ]
41
+ #[ cfg( feature = "urlencode " ) ]
42
42
const PYTHON_ENCODE_SET : & AsciiSet = & USERINFO_ENCODE_SET
43
43
. remove ( b'/' )
44
44
. add ( b':' )
@@ -214,15 +214,15 @@ pub fn capitalize(value: &Value, _: &HashMap<String, Value>) -> Result<Value> {
214
214
}
215
215
216
216
/// Percent-encodes reserved URI characters
217
- #[ cfg( feature = "builtins " ) ]
217
+ #[ cfg( feature = "urlencode " ) ]
218
218
pub fn urlencode ( value : & Value , _: & HashMap < String , Value > ) -> Result < Value > {
219
219
let s = try_get_value ! ( "urlencode" , "value" , String , value) ;
220
220
let encoded = percent_encode ( s. as_bytes ( ) , & PYTHON_ENCODE_SET ) . to_string ( ) ;
221
221
Ok ( Value :: String ( encoded) )
222
222
}
223
223
224
224
/// Percent-encodes all non-alphanumeric characters
225
- #[ cfg( feature = "builtins " ) ]
225
+ #[ cfg( feature = "urlencode " ) ]
226
226
pub fn urlencode_strict ( value : & Value , _: & HashMap < String , Value > ) -> Result < Value > {
227
227
let s = try_get_value ! ( "urlencode_strict" , "value" , String , value) ;
228
228
let encoded = percent_encode ( s. as_bytes ( ) , & NON_ALPHANUMERIC ) . to_string ( ) ;
@@ -596,7 +596,7 @@ mod tests {
596
596
}
597
597
}
598
598
599
- #[ cfg( feature = "builtins " ) ]
599
+ #[ cfg( feature = "urlencode " ) ]
600
600
#[ test]
601
601
fn test_urlencode ( ) {
602
602
let tests = vec ! [
@@ -620,7 +620,7 @@ mod tests {
620
620
}
621
621
}
622
622
623
- #[ cfg( feature = "builtins " ) ]
623
+ #[ cfg( feature = "urlencode " ) ]
624
624
#[ test]
625
625
fn test_urlencode_strict ( ) {
626
626
let tests = vec ! [
0 commit comments