MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / get_plugin_name

Function get_plugin_name

crates/opencode-config/src/loader.rs:1215–1229  ·  view source on GitHub ↗

Extract canonical plugin name from a specifier. - For file:// URLs: extracts filename without extension - For npm packages: extracts package name without version

(plugin: &str)

Source from the content-addressed store, hash-verified

1213/// - For file:// URLs: extracts filename without extension
1214/// - For npm packages: extracts package name without version
1215pub fn get_plugin_name(plugin: &str) -> String {
1216 if plugin.starts_with("file://") {
1217 return Path::new(plugin.trim_start_matches("file://"))
1218 .file_stem()
1219 .map(|s| s.to_string_lossy().to_string())
1220 .unwrap_or_else(|| plugin.to_string());
1221 }
1222 // For npm packages: strip version after last @
1223 if let Some(last_at) = plugin.rfind('@') {
1224 if last_at > 0 {
1225 return plugin[..last_at].to_string();
1226 }
1227 }
1228 plugin.to_string()
1229}
1230
1231/// Deduplicate plugins by name, with later entries (higher priority) winning.
1232/// Since plugins are added in low-to-high priority order,

Callers 1

deduplicate_pluginsFunction · 0.85

Calls 1

newFunction · 0.85

Tested by

no test coverage detected