diff --git a/src/NzbDrone.Core.Test/RemotePathMappingsTests/RemotePathMappingServiceFixture.cs b/src/NzbDrone.Core.Test/RemotePathMappingsTests/RemotePathMappingServiceFixture.cs index 47f023c1b..200f379b5 100644 --- a/src/NzbDrone.Core.Test/RemotePathMappingsTests/RemotePathMappingServiceFixture.cs +++ b/src/NzbDrone.Core.Test/RemotePathMappingsTests/RemotePathMappingServiceFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; @@ -135,5 +135,24 @@ namespace NzbDrone.Core.Test.RemotePathMappingsTests result.RemotePath.Should().Be(cleanedPath); } + + [TestCase(@" \\server\share\with\whitespace\ ", @"\\server\share\with\whitespace\")] + [TestCase(@" D:\with\whitespace\", @"D:\with\whitespace\")] + [TestCase(@"D:\with\whitespace\ ", @"D:\with\whitespace\")] + public void should_trim_whitespace_on_add(string remotePath, string cleanedPath) + { + GivenMapping(); + + var mapping = new RemotePathMapping + { + Host = "my-server.localdomain", + RemotePath = remotePath, + LocalPath = @"D:\mountedstorage\downloads\tv".AsOsAgnostic() + }; + + var result = Subject.Add(mapping); + + result.RemotePath.Should().Be(cleanedPath); + } } } diff --git a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs b/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs index 859bcbee4..a58554010 100644 --- a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs +++ b/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -50,8 +50,8 @@ namespace NzbDrone.Core.RemotePathMappings public RemotePathMapping Add(RemotePathMapping mapping) { - mapping.LocalPath = new OsPath(mapping.LocalPath).AsDirectory().FullPath; - mapping.RemotePath = new OsPath(mapping.RemotePath).AsDirectory().FullPath; + mapping.LocalPath = new OsPath(mapping.LocalPath.Trim()).AsDirectory().FullPath; + mapping.RemotePath = new OsPath(mapping.RemotePath.Trim()).AsDirectory().FullPath; var all = All();