From d2a89c66ab9f33357fd62841eaf35bacd14c90d3 Mon Sep 17 00:00:00 2001 From: pybt Date: Mon, 30 May 2022 20:18:04 +0700 Subject: [PATCH] add source.rs --- src/utils/source.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/utils/source.rs diff --git a/src/utils/source.rs b/src/utils/source.rs new file mode 100644 index 00000000..73e7297a --- /dev/null +++ b/src/utils/source.rs @@ -0,0 +1,9 @@ +use std::path::Path; + +use regex::Regex; + +pub fn validate_source(source: &str) -> bool +{ + let re = Regex::new(r"^https?://.*").unwrap(); + return Path::new(&source).is_file() || re.is_match(&source); +} \ No newline at end of file