|  | 
| 1 | 1 | use super::cacher::BoxedCacher; | 
| 2 | 2 | use super::error::ConfigError; | 
| 3 | 3 | use crate::format::Format; | 
|  | 4 | +use crate::helpers::*; | 
| 4 | 5 | use serde::Deserialize; | 
| 5 | 6 | use serde::{Serialize, de::DeserializeOwned}; | 
| 6 | 7 | use std::fs; | 
| @@ -169,44 +170,3 @@ impl Source { | 
| 169 | 170 |         } | 
| 170 | 171 |     } | 
| 171 | 172 | } | 
| 172 |  | - | 
| 173 |  | -/// Returns true if the value ends in a supported file extension. | 
| 174 |  | -pub fn is_source_format(value: &str) -> bool { | 
| 175 |  | -    value.ends_with(".json") | 
| 176 |  | -        || value.ends_with(".pkl") | 
| 177 |  | -        || value.ends_with(".toml") | 
| 178 |  | -        || value.ends_with(".yaml") | 
| 179 |  | -        || value.ends_with(".yml") | 
| 180 |  | -} | 
| 181 |  | - | 
| 182 |  | -/// Returns true if the value looks like a file, by checking for `file://`, | 
| 183 |  | -/// path separators, or supported file extensions. | 
| 184 |  | -pub fn is_file_like(value: &str) -> bool { | 
| 185 |  | -    value.starts_with("file://") | 
| 186 |  | -        || value.starts_with('/') | 
| 187 |  | -        || value.starts_with('\\') | 
| 188 |  | -        || value.starts_with('.') | 
| 189 |  | -        || value.contains('/') | 
| 190 |  | -        || value.contains('\\') | 
| 191 |  | -        || value.contains('.') | 
| 192 |  | -} | 
| 193 |  | - | 
| 194 |  | -/// Returns true if the value looks like a URL, by checking for `http://`, `https://`, or `www`. | 
| 195 |  | -pub fn is_url_like(value: &str) -> bool { | 
| 196 |  | -    value.starts_with("https://") || value.starts_with("http://") || value.starts_with("www") | 
| 197 |  | -} | 
| 198 |  | - | 
| 199 |  | -/// Returns true if the value is a secure URL, by checking for `https://`. This check can be | 
| 200 |  | -/// bypassed for localhost URLs. | 
| 201 |  | -pub fn is_secure_url(value: &str) -> bool { | 
| 202 |  | -    if value.contains("127.0.0.1") || value.contains("//localhost") { | 
| 203 |  | -        return true; | 
| 204 |  | -    } | 
| 205 |  | - | 
| 206 |  | -    value.starts_with("https://") | 
| 207 |  | -} | 
| 208 |  | - | 
| 209 |  | -/// Strip a leading BOM from the string. | 
| 210 |  | -pub fn strip_bom(content: &str) -> &str { | 
| 211 |  | -    content.trim_start_matches("\u{feff}") | 
| 212 |  | -} | 
0 commit comments