Skip to content

Commit b426dd1

Browse files
committed
Rewrite LocationPathString match
1 parent 79962fb commit b426dd1

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4+
using System.Text.RegularExpressions;
45
using System.Windows;
56

67
namespace Flow.Launcher.Plugin.SharedCommands
@@ -142,35 +143,28 @@ public static void OpenContainingFolder(string path)
142143
Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
143144
}
144145

146+
145147
///<summary>
146148
/// This checks whether a given string is a directory path or network location string.
147149
/// It does not check if location actually exists.
148150
///</summary>
149151
public static bool IsLocationPathString(string querySearchString)
150152
{
151-
if (string.IsNullOrEmpty(querySearchString))
153+
if (string.IsNullOrEmpty(querySearchString) || querySearchString.Length < 3)
152154
return false;
153155

154156
// // shared folder location, and not \\\location\
155-
if (querySearchString.Length >= 3
156-
&& querySearchString.StartsWith(@"\\")
157-
&& char.IsLetter(querySearchString[2]))
157+
if (querySearchString.StartsWith(@"\\")
158+
&& querySearchString[2] != '\\')
158159
return true;
159160

160161
// c:\
161-
if (querySearchString.Length == 3
162-
&& char.IsLetter(querySearchString[0])
162+
if (char.IsLetter(querySearchString[0])
163163
&& querySearchString[1] == ':'
164164
&& querySearchString[2] == '\\')
165-
return true;
166-
167-
// c:\\
168-
if (querySearchString.Length >= 4
169-
&& char.IsLetter(querySearchString[0])
170-
&& querySearchString[1] == ':'
171-
&& querySearchString[2] == '\\'
172-
&& char.IsLetter(querySearchString[3]))
173-
return true;
165+
{
166+
return querySearchString.Length == 3 || querySearchString[3] != '\\';
167+
}
174168

175169
return false;
176170
}

0 commit comments

Comments
 (0)