File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Plugins/Flow.Launcher.Plugin.Program/Programs Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -737,6 +737,17 @@ public static void Dispose()
737
737
}
738
738
}
739
739
740
+ // https://stackoverflow.com/a/66877016
741
+ private static bool IsSubPathOf ( string subPath , string basePath )
742
+ {
743
+ var rel = Path . GetRelativePath ( basePath , subPath ) ;
744
+ return rel != "."
745
+ && rel != ".."
746
+ && ! rel . StartsWith ( "../" )
747
+ && ! rel . StartsWith ( @"..\" )
748
+ && ! Path . IsPathRooted ( rel ) ;
749
+ }
750
+
740
751
private static List < string > GetCommonParents ( IEnumerable < ProgramSource > programSources )
741
752
{
742
753
// To avoid unnecessary io
@@ -748,8 +759,8 @@ private static List<string> GetCommonParents(IEnumerable<ProgramSource> programS
748
759
HashSet < ProgramSource > parents = group . ToHashSet ( ) ;
749
760
foreach ( var source in group )
750
761
{
751
- if ( parents . Any ( p => source . Location . StartsWith ( p . Location , StringComparison . OrdinalIgnoreCase ) &&
752
- source != p ) )
762
+ if ( parents . Any ( p => IsSubPathOf ( source . Location , p . Location ) &&
763
+ source != p ) ) // TODO startwith not accurate
753
764
{
754
765
parents . Remove ( source ) ;
755
766
}
You can’t perform that action at this time.
0 commit comments