From d5a869ac54812a5a0dfbf8d9f771926815462ce0 Mon Sep 17 00:00:00 2001 From: Scott Schlesier Date: Sat, 6 Nov 2010 09:01:46 -0700 Subject: [PATCH] Parse UNC paths --- NzbDrone.Core.Test/ParserTest.cs | 1 + NzbDrone.Core/Parser.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index dad7b1a87..3d1c3f19a 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -58,6 +58,7 @@ namespace NzbDrone.Core.Test [Row(@"c:\\test\\", @"c:\test")] [Row(@"C:\\Test\\", @"c:\test")] [Row(@"C:\\Test\\Test\", @"c:\test\test")] + [Row(@"\\Testserver\Test\", @"\\testserver\test")] public void Normalize_Path(string dirty, string clean) { var result = Parser.NormalizePath(dirty); diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index df2d18618..661898e36 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -130,11 +130,20 @@ namespace NzbDrone.Core return NormalizeRegex.Replace(title, String.Empty).ToLower(); } + //Note: changing case on path is a problem for running on mono/*nix public static string NormalizePath(string path) { if (String.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty"); - return new FileInfo(path).FullName.ToLower().Trim('/', '\\', ' '); + + var info = new FileInfo(path); + + if( info.FullName.StartsWith(@"\\")) //UNC + { + return info.FullName.ToLower().TrimEnd('/', '\\', ' '); + } + + return info.FullName.ToLower().Trim('/', '\\', ' '); } } }