@@ -12,8 +12,7 @@ use tauri::{AppHandle, Manager};
1212
1313const VENCORD_REPO : & str = "https://github.com/Vendicated/Vencord.git" ;
1414const MANIFEST_FILE : & str = "manifest.json" ;
15- const REQUIRED_DIST_FILES : [ & str ; 5 ] = [
16- "package.json" ,
15+ const REQUIRED_DIST_FILES : [ & str ; 4 ] = [
1716 "vencordDesktopMain.js" ,
1817 "vencordDesktopPreload.js" ,
1918 "vencordDesktopRenderer.js" ,
@@ -274,8 +273,21 @@ fn plugin_name_from_source(source: &PluginSource, fallback: Option<String>) -> S
274273 }
275274}
276275
276+ fn trim_wrapping_quotes ( input : & str ) -> String {
277+ let trimmed = input. trim ( ) ;
278+ if trimmed. len ( ) >= 2 {
279+ let bytes = trimmed. as_bytes ( ) ;
280+ let first = bytes[ 0 ] ;
281+ let last = bytes[ bytes. len ( ) - 1 ] ;
282+ if ( first == b'"' && last == b'"' ) || ( first == b'\'' && last == b'\'' ) {
283+ return trimmed[ 1 ..trimmed. len ( ) - 1 ] . trim ( ) . to_string ( ) ;
284+ }
285+ }
286+ trimmed. to_string ( )
287+ }
288+
277289fn normalize_github_plugin_url ( url : & str ) -> Result < String , String > {
278- let trimmed = url . trim ( ) ;
290+ let trimmed = trim_wrapping_quotes ( url ) ;
279291 let without_scheme = trimmed
280292 . strip_prefix ( "https://github.com/" )
281293 . ok_or_else ( || "Git plugin sources must be HTTPS GitHub repository URLs." . to_string ( ) ) ?;
@@ -1063,10 +1075,12 @@ fn get_environment_status(app: AppHandle) -> Result<EnvironmentStatus, String> {
10631075fn add_plugin ( app : AppHandle , request : AddPluginRequest ) -> Result < Manifest , String > {
10641076 let source = match request. source {
10651077 PluginSource :: LocalFile { path } => {
1078+ let path = trim_wrapping_quotes ( & path) ;
10661079 validate_local_plugin_path ( Path :: new ( & path) ) ?;
10671080 PluginSource :: LocalFile { path }
10681081 }
10691082 PluginSource :: LocalFolder { path } => {
1083+ let path = trim_wrapping_quotes ( & path) ;
10701084 validate_local_plugin_path ( Path :: new ( & path) ) ?;
10711085 PluginSource :: LocalFolder { path }
10721086 }
@@ -1430,6 +1444,32 @@ mod tests {
14301444 ) ;
14311445 }
14321446
1447+ #[ test]
1448+ fn source_inputs_trim_wrapping_quotes ( ) {
1449+ assert_eq ! (
1450+ trim_wrapping_quotes( r#""D:\Descargas\jn v2\discord-gfm-tables.plugin.js""# ) ,
1451+ r#"D:\Descargas\jn v2\discord-gfm-tables.plugin.js"#
1452+ ) ;
1453+ assert_eq ! (
1454+ normalize_github_plugin_url( "'https://github.com/Microck/discord-gfm-tables'" ) . unwrap( ) ,
1455+ "https://github.com/Microck/discord-gfm-tables.git"
1456+ ) ;
1457+ }
1458+
1459+ #[ test]
1460+ fn dist_validation_matches_current_vencord_desktop_outputs ( ) {
1461+ let dir = env:: temp_dir ( ) . join ( format ! ( "veskforge-dist-test-{}" , now_stamp( ) ) ) ;
1462+ fs:: create_dir_all ( & dir) . unwrap ( ) ;
1463+ for file in REQUIRED_DIST_FILES {
1464+ fs:: write ( dir. join ( file) , "" ) . unwrap ( ) ;
1465+ }
1466+
1467+ assert ! ( validate_dist( & dir) . is_ok( ) ) ;
1468+ assert ! ( !REQUIRED_DIST_FILES . contains( & "package.json" ) ) ;
1469+
1470+ fs:: remove_dir_all ( dir) . unwrap ( ) ;
1471+ }
1472+
14331473 #[ test]
14341474 fn materialized_plugin_requires_index_entrypoint ( ) {
14351475 let dir = env:: temp_dir ( ) . join ( format ! ( "veskforge-entrypoint-test-{}" , now_stamp( ) ) ) ;
0 commit comments