pub fn resolve_output_path(
output_arg: Option<String>,
url: &str,
default_name: &str,
) -> StringExpand description
Resolve the final output path for a download.
Handles three cases:
output_argisNone: Extract filename from URLoutput_argis a directory: Append filename from URL to directoryoutput_argis a file path: Use it directly
§Arguments
output_arg- User-provided output path (can be file or directory)url- Source URL for filename extractiondefault_name- Fallback filename if URL doesn’t contain one
§Returns
The resolved output file path.
§Example
use kget::resolve_output_path;
// No output specified - use filename from URL
let path = resolve_output_path(None, "https://example.com/file.zip", "download");
assert_eq!(path, "file.zip");
// Custom filename
let path = resolve_output_path(Some("myfile.zip".to_string()), "https://example.com/file.zip", "download");
assert_eq!(path, "myfile.zip");