mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Rewrite LocationPathString match
This commit is contained in:
parent
79962fb03e
commit
b426dd10d1
1 changed files with 9 additions and 15 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
|
||||
namespace Flow.Launcher.Plugin.SharedCommands
|
||||
|
|
@ -142,35 +143,28 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
|||
Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
|
||||
}
|
||||
|
||||
|
||||
///<summary>
|
||||
/// This checks whether a given string is a directory path or network location string.
|
||||
/// It does not check if location actually exists.
|
||||
///</summary>
|
||||
public static bool IsLocationPathString(string querySearchString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(querySearchString))
|
||||
if (string.IsNullOrEmpty(querySearchString) || querySearchString.Length < 3)
|
||||
return false;
|
||||
|
||||
// // shared folder location, and not \\\location\
|
||||
if (querySearchString.Length >= 3
|
||||
&& querySearchString.StartsWith(@"\\")
|
||||
&& char.IsLetter(querySearchString[2]))
|
||||
if (querySearchString.StartsWith(@"\\")
|
||||
&& querySearchString[2] != '\\')
|
||||
return true;
|
||||
|
||||
// c:\
|
||||
if (querySearchString.Length == 3
|
||||
&& char.IsLetter(querySearchString[0])
|
||||
if (char.IsLetter(querySearchString[0])
|
||||
&& querySearchString[1] == ':'
|
||||
&& querySearchString[2] == '\\')
|
||||
return true;
|
||||
|
||||
// c:\\
|
||||
if (querySearchString.Length >= 4
|
||||
&& char.IsLetter(querySearchString[0])
|
||||
&& querySearchString[1] == ':'
|
||||
&& querySearchString[2] == '\\'
|
||||
&& char.IsLetter(querySearchString[3]))
|
||||
return true;
|
||||
{
|
||||
return querySearchString.Length == 3 || querySearchString[3] != '\\';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue