Skip to content

Commit

Permalink
- use Url::parse to determine the existance of url.
Browse files Browse the repository at this point in the history
  • Loading branch information
laststylebender14 committed May 1, 2024
1 parent 8410bfd commit 78c4566
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/config/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rustls_pemfile;
use rustls_pki_types::{
CertificateDer, PrivateKeyDer, PrivatePkcs1KeyDer, PrivatePkcs8KeyDer, PrivateSec1KeyDer,
};
use url::Url;

use super::{ConfigModule, Content, Link, LinkType};
use crate::config::{Config, ConfigReaderContext, Source};
Expand Down Expand Up @@ -215,7 +216,9 @@ impl ConfigReader {

/// checks and returns valid path for caller function.
fn resolve_path(src: &str, root_dir: Option<&Path>) -> String {
if src.starts_with("http") || Path::new(&src).is_absolute() {
if let Ok(url) = Url::parse(src) {
url.to_string()
} else if Path::new(&src).is_absolute() {
src.to_string()
} else {
let path = root_dir.unwrap_or(Path::new(""));
Expand Down

0 comments on commit 78c4566

Please sign in to comment.