Skip to content

Commit 40dfa4d

Browse files
committed
rename feature to urlencode
1 parent e636269 commit 40dfa4d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ tempfile = "3"
4343

4444
[features]
4545
default = ["builtins"]
46-
builtins = ["builtins_urlencode", "slug", "humansize", "chrono", "chrono-tz", "rand"]
47-
builtins_urlencode = ["percent-encoding"]
46+
builtins = ["urlencode", "slug", "humansize", "chrono", "chrono-tz", "rand"]
47+
urlencode = ["percent-encoding"]
4848
preserve_order = ["serde_json/preserve_order"]
4949

5050
[badges]

src/builtins/filters/string.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ use regex::{Captures, Regex};
66
use serde_json::value::{to_value, Value};
77
use unic_segment::GraphemeIndices;
88

9-
#[cfg(feature = "builtins_urlencode")]
9+
#[cfg(feature = "urlencode")]
1010
use percent_encoding::{percent_encode, AsciiSet, NON_ALPHANUMERIC};
1111

1212
use crate::errors::{Error, Result};
1313
use crate::utils;
1414

1515
/// https://url.spec.whatwg.org/#fragment-percent-encode-set
16-
#[cfg(feature = "builtins_urlencode")]
16+
#[cfg(feature = "urlencode")]
1717
const FRAGMENT_ENCODE_SET: &AsciiSet =
1818
&percent_encoding::CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
1919

2020
/// https://url.spec.whatwg.org/#path-percent-encode-set
21-
#[cfg(feature = "builtins_urlencode")]
21+
#[cfg(feature = "urlencode")]
2222
const PATH_ENCODE_SET: &AsciiSet = &FRAGMENT_ENCODE_SET.add(b'#').add(b'?').add(b'{').add(b'}');
2323

2424
/// https://url.spec.whatwg.org/#userinfo-percent-encode-set
25-
#[cfg(feature = "builtins_urlencode")]
25+
#[cfg(feature = "urlencode")]
2626
const USERINFO_ENCODE_SET: &AsciiSet = &PATH_ENCODE_SET
2727
.add(b'/')
2828
.add(b':')
@@ -38,7 +38,7 @@ const USERINFO_ENCODE_SET: &AsciiSet = &PATH_ENCODE_SET
3838
/// Same as Python quote
3939
/// https://github.com/python/cpython/blob/da27d9b9dc44913ffee8f28d9638985eaaa03755/Lib/urllib/parse.py#L787
4040
/// with `/` not escaped
41-
#[cfg(feature = "builtins_urlencode")]
41+
#[cfg(feature = "urlencode")]
4242
const PYTHON_ENCODE_SET: &AsciiSet = &USERINFO_ENCODE_SET
4343
.remove(b'/')
4444
.add(b':')
@@ -214,15 +214,15 @@ pub fn capitalize(value: &Value, _: &HashMap<String, Value>) -> Result<Value> {
214214
}
215215

216216
/// Percent-encodes reserved URI characters
217-
#[cfg(feature = "builtins_urlencode")]
217+
#[cfg(feature = "urlencode")]
218218
pub fn urlencode(value: &Value, _: &HashMap<String, Value>) -> Result<Value> {
219219
let s = try_get_value!("urlencode", "value", String, value);
220220
let encoded = percent_encode(s.as_bytes(), &PYTHON_ENCODE_SET).to_string();
221221
Ok(Value::String(encoded))
222222
}
223223

224224
/// Percent-encodes all non-alphanumeric characters
225-
#[cfg(feature = "builtins_urlencode")]
225+
#[cfg(feature = "urlencode")]
226226
pub fn urlencode_strict(value: &Value, _: &HashMap<String, Value>) -> Result<Value> {
227227
let s = try_get_value!("urlencode_strict", "value", String, value);
228228
let encoded = percent_encode(s.as_bytes(), &NON_ALPHANUMERIC).to_string();
@@ -596,7 +596,7 @@ mod tests {
596596
}
597597
}
598598

599-
#[cfg(feature = "builtins_urlencode")]
599+
#[cfg(feature = "urlencode")]
600600
#[test]
601601
fn test_urlencode() {
602602
let tests = vec![
@@ -620,7 +620,7 @@ mod tests {
620620
}
621621
}
622622

623-
#[cfg(feature = "builtins_urlencode")]
623+
#[cfg(feature = "urlencode")]
624624
#[test]
625625
fn test_urlencode_strict() {
626626
let tests = vec![

src/tera.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,9 @@ impl Tera {
580580
self.register_filter("linebreaksbr", string::linebreaksbr);
581581
self.register_filter("striptags", string::striptags);
582582
self.register_filter("spaceless", string::spaceless);
583-
#[cfg(feature = "builtins_urlencode")]
583+
#[cfg(feature = "urlencode")]
584584
self.register_filter("urlencode", string::urlencode);
585-
#[cfg(feature = "builtins_urlencode")]
585+
#[cfg(feature = "urlencode")]
586586
self.register_filter("urlencode_strict", string::urlencode_strict);
587587
self.register_filter("escape", string::escape_html);
588588
self.register_filter("escape_xml", string::escape_xml);

0 commit comments

Comments
 (0)