From 15da2558cb0922ed22d7eea120cd4826f3b02b57 Mon Sep 17 00:00:00 2001 From: Olivier Borderies Date: Tue, 14 May 2024 22:26:29 +0200 Subject: [PATCH] Improve file:// url parsing --- utoipa-swagger-ui/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utoipa-swagger-ui/build.rs b/utoipa-swagger-ui/build.rs index 65e56c38..a2541a40 100644 --- a/utoipa-swagger-ui/build.rs +++ b/utoipa-swagger-ui/build.rs @@ -1,3 +1,4 @@ +use reqwest::Url; use std::{ env, error::Error, @@ -37,7 +38,7 @@ fn main() { println!("start download to : {:?}", zip_path); download_file(&url, zip_path.clone()).unwrap(); } else if url.starts_with("file://") { - let file_path = url.replace("file://", ""); + let file_path = Url::parse(&url).unwrap().to_file_path().unwrap(); println!("start copy to : {:?}", zip_path); fs::copy(file_path, zip_path.clone()).unwrap(); } else {