INNER CODE UNIT · Rust

add_plugin_from_url

Drew-Alleman/DataSurgeon · src/plugins/mod.rs:196

pub fn add_plugin_from_url(url: &str) -> bool {
    // Format the URL to point to the raw plugins.json file
    let trimmed_url = url.trim_end_matches('/');
    let github_file_url = format!("{}/main/plugins.json", trimmed_url);
    let github_raw_url = github_file_url.replace("github.com", "raw.githubusercontent.com");
    let plugins: Vec<RegexPlugin> = match get_plugins_from_url(&github_raw_url) {
        Ok(mut plugins) => {
            for plugin in &mut plugins {
                // Update the source_url of the plugin to match the provided URL
                plugin.source_url = trimmed_url.to_string();
            }
            plugins
        },
        Err(e) => {
            eprintln!("[-] Error: Failed to parse plugins.json from the provided URL. Reason: {}", e);
            std::process::exit(1);
        }
    };

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…