| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#; |
| 2 | |
| 3 | extern crate regexrust-analyzer cargo sanitize-filename 0.6.0 regex/; |
| 4 | use regexrust-analyzer cargo regex 1.11.1 crate/::{Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#, RegexBuilderrust-analyzer cargo regex 1.11.1 builders/string/RegexBuilder#}; |
| 5 | |
| 6 | static ILLEGAL_RErust-analyzer cargo sanitize-filename 0.6.0 ILLEGAL_RE.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 7 | static CONTROL_RErust-analyzer cargo sanitize-filename 0.6.0 CONTROL_RE.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 8 | static RESERVED_RErust-analyzer cargo sanitize-filename 0.6.0 RESERVED_RE.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 9 | static WINDOWS_RESERVED_RErust-analyzer cargo sanitize-filename 0.6.0 WINDOWS_RESERVED_RE.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 10 | static WINDOWS_TRAILING_RErust-analyzer cargo sanitize-filename 0.6.0 WINDOWS_TRAILING_RE.: OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#> = OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().(); |
| 11 | |
| 12 | fn illegal_rerust-analyzer cargo sanitize-filename 0.6.0 illegal_re().() -> &'static Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex# { |
| 13 | ILLEGAL_RErust-analyzer cargo sanitize-filename 0.6.0 ILLEGAL_RE..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#::newrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]new().(r#"[/\?<>\\:\*\|":]"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 14 | } |
| 15 | |
| 16 | fn control_rerust-analyzer cargo sanitize-filename 0.6.0 control_re().() -> &'static Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex# { |
| 17 | CONTROL_RErust-analyzer cargo sanitize-filename 0.6.0 CONTROL_RE..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#::newrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]new().(r#"[\x00-\x1f\x80-\x9f]"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 18 | } |
| 19 | |
| 20 | fn reserved_rerust-analyzer cargo sanitize-filename 0.6.0 reserved_re().() -> &'static Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex# { |
| 21 | RESERVED_RErust-analyzer cargo sanitize-filename 0.6.0 RESERVED_RE..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#::newrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]new().(r#"^\.+$"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 22 | } |
| 23 | |
| 24 | fn windows_reserved_rerust-analyzer cargo sanitize-filename 0.6.0 windows_reserved_re().() -> &'static Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex# { |
| 25 | WINDOWS_RESERVED_RErust-analyzer cargo sanitize-filename 0.6.0 WINDOWS_RESERVED_RE..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| { |
| 26 | RegexBuilderrust-analyzer cargo regex 1.11.1 builders/string/RegexBuilder#::newrust-analyzer cargo regex 1.11.1 builders/string/impl#[RegexBuilder]new().(r#"(?i)^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$"#) |
| 27 | .case_insensitiverust-analyzer cargo regex 1.11.1 builders/string/impl#[RegexBuilder]case_insensitive().(true) |
| 28 | .buildrust-analyzer cargo regex 1.11.1 builders/string/impl#[RegexBuilder]build().() |
| 29 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | fn windows_trailing_rerust-analyzer cargo sanitize-filename 0.6.0 windows_trailing_re().() -> &'static Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex# { |
| 34 | WINDOWS_TRAILING_RErust-analyzer cargo sanitize-filename 0.6.0 WINDOWS_TRAILING_RE..get_or_initrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get_or_init().(|| Regexrust-analyzer cargo regex 1.11.1 regex/string/Regex#::newrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]new().(r#"[\. ]+$"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 35 | } |
| 36 | |
| 37 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 38 | pub struct Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options#<'a> { |
| 39 | pub windowsrust-analyzer cargo sanitize-filename 0.6.0 Options#windows.: bool, |
| 40 | pub truncaterust-analyzer cargo sanitize-filename 0.6.0 Options#truncate.: bool, |
| 41 | pub replacementrust-analyzer cargo sanitize-filename 0.6.0 Options#replacement.: &'a str, |
| 42 | } |
| 43 | |
| 44 | impl<'a> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options#<'a> { |
| 45 | fn defaultrust-analyzer cargo sanitize-filename 0.6.0 impl#[`Options<'a>`][Default]default().() -> Selfrust-analyzer cargo sanitize-filename 0.6.0 impl#[`Options<'a>`][Default] { |
| 46 | Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options# { |
| 47 | windowsrust-analyzer cargo sanitize-filename 0.6.0 Options#windows.: cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(windows), |
| 48 | truncaterust-analyzer cargo sanitize-filename 0.6.0 Options#truncate.: true, |
| 49 | replacementrust-analyzer cargo sanitize-filename 0.6.0 Options#replacement.: "", |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | pub fn sanitizerust-analyzer cargo sanitize-filename 0.6.0 sanitize().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(name: S) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 55 | sanitize_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 sanitize_with_options().(name, Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options#::defaultrust-analyzer cargo sanitize-filename 0.6.0 impl#[`Options<'a>`][Default]default().()) |
| 56 | } |
| 57 | |
| 58 | pub fn sanitize_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 sanitize_with_options().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(name: S, options: Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 59 | let Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options# { |
| 60 | windowsrust-analyzer cargo sanitize-filename 0.6.0 Options#windows., |
| 61 | truncaterust-analyzer cargo sanitize-filename 0.6.0 Options#truncate., |
| 62 | replacementrust-analyzer cargo sanitize-filename 0.6.0 Options#replacement., |
| 63 | } = options; |
| 64 | let name = name.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 65 | |
| 66 | let name = illegal_rerust-analyzer cargo sanitize-filename 0.6.0 illegal_re().().replace_allrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]replace_all().(&name, replacement); |
| 67 | let name = control_rerust-analyzer cargo sanitize-filename 0.6.0 control_re().().replace_allrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]replace_all().(&name, replacement); |
| 68 | let name = reserved_rerust-analyzer cargo sanitize-filename 0.6.0 reserved_re().().replacerust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]replace().(&name, replacement); |
| 69 | |
| 70 | let collect = |name: ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<str>| { |
| 71 | if truncate && name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().255 { |
| 72 | let mut end = 255; |
| 73 | loop { |
| 74 | if name.is_char_boundaryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_char_boundary().(end) { |
| 75 | break; |
| 76 | } |
| 77 | end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1; |
| 78 | } |
| 79 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().(&name[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 80 | } else { |
| 81 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<Cow<'a, str>>`]from().(name) |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | if windows { |
| 86 | let name = windows_reserved_rerust-analyzer cargo sanitize-filename 0.6.0 windows_reserved_re().().replacerust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]replace().(&name, replacement); |
| 87 | let name = windows_trailing_rerust-analyzer cargo sanitize-filename 0.6.0 windows_trailing_re().().replacerust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]replace().(&name, replacement); |
| 88 | collect(name) |
| 89 | } else { |
| 90 | collect(name) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 95 | pub struct OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck# { |
| 96 | pub windowsrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#windows.: bool, |
| 97 | pub truncaterust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#truncate.: bool, |
| 98 | } |
| 99 | |
| 100 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck# { |
| 101 | fn defaultrust-analyzer cargo sanitize-filename 0.6.0 impl#[OptionsForCheck][Default]default().() -> Selfrust-analyzer cargo sanitize-filename 0.6.0 impl#[OptionsForCheck][Default] { |
| 102 | OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck# { |
| 103 | windowsrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#windows.: cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(windows), |
| 104 | truncaterust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#truncate.: true, |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | pub fn is_sanitizedrust-analyzer cargo sanitize-filename 0.6.0 is_sanitized().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(name: S) -> bool { |
| 110 | is_sanitized_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 is_sanitized_with_options().(name, OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#::defaultrust-analyzer cargo sanitize-filename 0.6.0 impl#[OptionsForCheck][Default]default().()) |
| 111 | } |
| 112 | |
| 113 | pub fn is_sanitized_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 is_sanitized_with_options().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(name: S, options: OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#) -> bool { |
| 114 | let OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck# { windowsrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#windows., truncaterust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#truncate. } = options; |
| 115 | let name = name.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 116 | |
| 117 | if illegal_rerust-analyzer cargo sanitize-filename 0.6.0 illegal_re().().is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(&name) { |
| 118 | return false; |
| 119 | } |
| 120 | if control_rerust-analyzer cargo sanitize-filename 0.6.0 control_re().().is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(&name) { |
| 121 | return false; |
| 122 | } |
| 123 | if reserved_rerust-analyzer cargo sanitize-filename 0.6.0 reserved_re().().is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(&name) { |
| 124 | return false; |
| 125 | } |
| 126 | if truncate && name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().255 { |
| 127 | return false; |
| 128 | } |
| 129 | if windows { |
| 130 | if windows_reserved_rerust-analyzer cargo sanitize-filename 0.6.0 windows_reserved_re().().is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(&name) { |
| 131 | return false; |
| 132 | } |
| 133 | if windows_trailing_rerust-analyzer cargo sanitize-filename 0.6.0 windows_trailing_re().().is_matchrust-analyzer cargo regex 1.11.1 regex/string/impl#[Regex]is_match().(&name) { |
| 134 | return false; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | #[cfg(test)] |
| 142 | mod testsrust-analyzer cargo sanitize-filename 0.6.0 tests/ { |
| 143 | |
| 144 | // From https://github.com/parshap/node-sanitize-filename/blob/master/test.js |
| 145 | static NAMESrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES.: &'static [&'static str] = &[ |
| 146 | "the quick brown fox jumped over the lazy dog", |
| 147 | "résumé", |
| 148 | "hello\u{0000}world", |
| 149 | "hello\nworld", |
| 150 | "semi;colon.js", |
| 151 | ";leading-semi.js", |
| 152 | "slash\\.js", |
| 153 | "slash/.js", |
| 154 | "col:on.js", |
| 155 | "star*.js", |
| 156 | "question?.js", |
| 157 | "quote\".js", |
| 158 | "singlequote'.js", |
| 159 | "brack<e>ts.js", |
| 160 | "p|pes.js", |
| 161 | "plus+.js", |
| 162 | "'five and six<seven'.js", |
| 163 | " space at front", |
| 164 | "space at end ", |
| 165 | ".period", |
| 166 | "period.", |
| 167 | "relative/path/to/some/dir", |
| 168 | "/abs/path/to/some/dir", |
| 169 | "~/.\u{0000}notssh/authorized_keys", |
| 170 | "", |
| 171 | "h?w", |
| 172 | "h/w", |
| 173 | "h*w", |
| 174 | ".", |
| 175 | "..", |
| 176 | "./", |
| 177 | "../", |
| 178 | "/..", |
| 179 | "/../", |
| 180 | "*.|.", |
| 181 | "./", |
| 182 | "./foobar", |
| 183 | "../foobar", |
| 184 | "../../foobar", |
| 185 | "./././foobar", |
| 186 | "|*.what", |
| 187 | "LPT9.asdf", |
| 188 | "foobar...", |
| 189 | ]; |
| 190 | |
| 191 | static NAMES_CLEANEDrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES_CLEANED.: &'static [&'static str] = &[ |
| 192 | "the quick brown fox jumped over the lazy dog", |
| 193 | "résumé", |
| 194 | "helloworld", |
| 195 | "helloworld", |
| 196 | "semi;colon.js", |
| 197 | ";leading-semi.js", |
| 198 | "slash.js", |
| 199 | "slash.js", |
| 200 | "colon.js", |
| 201 | "star.js", |
| 202 | "question.js", |
| 203 | "quote.js", |
| 204 | "singlequote'.js", |
| 205 | "brackets.js", |
| 206 | "ppes.js", |
| 207 | "plus+.js", |
| 208 | "'five and sixseven'.js", |
| 209 | " space at front", |
| 210 | "space at end", |
| 211 | ".period", |
| 212 | "period", |
| 213 | "relativepathtosomedir", |
| 214 | "abspathtosomedir", |
| 215 | "~.notsshauthorized_keys", |
| 216 | "", |
| 217 | "hw", |
| 218 | "hw", |
| 219 | "hw", |
| 220 | "", |
| 221 | "", |
| 222 | "", |
| 223 | "", |
| 224 | "", |
| 225 | "", |
| 226 | "", |
| 227 | "", |
| 228 | ".foobar", |
| 229 | "..foobar", |
| 230 | "....foobar", |
| 231 | "...foobar", |
| 232 | ".what", |
| 233 | "", |
| 234 | "foobar", |
| 235 | ]; |
| 236 | |
| 237 | static NAMES_IS_SANITIZEDrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES_IS_SANITIZED.: &'static [bool] = &[ |
| 238 | true, true, false, false, true, true, false, false, false, false, false, false, true, |
| 239 | false, false, true, false, true, false, true, false, false, false, false, true, false, |
| 240 | false, false, false, false, false, false, false, false, false, false, false, false, false, |
| 241 | false, false, false, false, |
| 242 | ]; |
| 243 | |
| 244 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 245 | fn it_worksrust-analyzer cargo sanitize-filename 0.6.0 tests/it_works().() { |
| 246 | // sanitize |
| 247 | let options = superrust-analyzer cargo sanitize-filename 0.6.0 crate/::Optionsrust-analyzer cargo sanitize-filename 0.6.0 Options# { |
| 248 | windowsrust-analyzer cargo sanitize-filename 0.6.0 Options#windows.: true, |
| 249 | truncaterust-analyzer cargo sanitize-filename 0.6.0 Options#truncate.: true, |
| 250 | replacementrust-analyzer cargo sanitize-filename 0.6.0 Options#replacement.: "", |
| 251 | }; |
| 252 | |
| 253 | for (idx, name) in NAMESrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 254 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 255 | superrust-analyzer cargo sanitize-filename 0.6.0 crate/::sanitize_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 sanitize_with_options().(name, options.clonerust-analyzer cargo sanitize-filename 0.6.0 impl#[`Options<'a>`][Clone]clone().()), |
| 256 | NAMES_CLEANEDrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES_CLEANED.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 257 | ); |
| 258 | } |
| 259 | |
| 260 | let long = ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().('a').takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(300).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 261 | let shorter = ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().('a').takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(255).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 262 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo sanitize-filename 0.6.0 crate/::sanitize_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 sanitize_with_options().(long, options.clonerust-analyzer cargo sanitize-filename 0.6.0 impl#[`Options<'a>`][Clone]clone().()), shorter); |
| 263 | |
| 264 | // is_sanitized |
| 265 | let options = superrust-analyzer cargo sanitize-filename 0.6.0 crate/::OptionsForCheckrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck# { |
| 266 | windowsrust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#windows.: true, |
| 267 | truncaterust-analyzer cargo sanitize-filename 0.6.0 OptionsForCheck#truncate.: true, |
| 268 | }; |
| 269 | |
| 270 | for (idx, name) in NAMESrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 271 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 272 | superrust-analyzer cargo sanitize-filename 0.6.0 crate/::is_sanitized_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 is_sanitized_with_options().(name, options.clonerust-analyzer cargo sanitize-filename 0.6.0 impl#[OptionsForCheck][Clone]clone().()), |
| 273 | NAMES_IS_SANITIZEDrust-analyzer cargo sanitize-filename 0.6.0 tests/NAMES_IS_SANITIZED.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 274 | ); |
| 275 | } |
| 276 | |
| 277 | let long = ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().('a').takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(300).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 278 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 279 | superrust-analyzer cargo sanitize-filename 0.6.0 crate/::is_sanitized_with_optionsrust-analyzer cargo sanitize-filename 0.6.0 is_sanitized_with_options().(long, options.clonerust-analyzer cargo sanitize-filename 0.6.0 impl#[OptionsForCheck][Clone]clone().()), |
| 280 | false |
| 281 | ); |
| 282 | } |
| 283 | } |