Extract canonical plugin name from a specifier. - For file:// URLs: extracts filename without extension - For npm packages: extracts package name without version
(plugin: &str)
| 1213 | /// - For file:// URLs: extracts filename without extension |
| 1214 | /// - For npm packages: extracts package name without version |
| 1215 | pub 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, |
no test coverage detected