|
1 | 1 | using System;
|
2 | 2 | using System.Diagnostics;
|
3 | 3 | using System.IO;
|
| 4 | +using System.Text.RegularExpressions; |
4 | 5 | using System.Windows;
|
5 | 6 |
|
6 | 7 | namespace Flow.Launcher.Plugin.SharedCommands
|
@@ -142,35 +143,28 @@ public static void OpenContainingFolder(string path)
|
142 | 143 | Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
|
143 | 144 | }
|
144 | 145 |
|
| 146 | + |
145 | 147 | ///<summary>
|
146 | 148 | /// This checks whether a given string is a directory path or network location string.
|
147 | 149 | /// It does not check if location actually exists.
|
148 | 150 | ///</summary>
|
149 | 151 | public static bool IsLocationPathString(string querySearchString)
|
150 | 152 | {
|
151 |
| - if (string.IsNullOrEmpty(querySearchString)) |
| 153 | + if (string.IsNullOrEmpty(querySearchString) || querySearchString.Length < 3) |
152 | 154 | return false;
|
153 | 155 |
|
154 | 156 | // // 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] != '\\') |
158 | 159 | return true;
|
159 | 160 |
|
160 | 161 | // c:\
|
161 |
| - if (querySearchString.Length == 3 |
162 |
| - && char.IsLetter(querySearchString[0]) |
| 162 | + if (char.IsLetter(querySearchString[0]) |
163 | 163 | && querySearchString[1] == ':'
|
164 | 164 | && 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 | + } |
174 | 168 |
|
175 | 169 | return false;
|
176 | 170 | }
|
|
0 commit comments