diff --git a/src/Couchbase.AspNet/CouchbaseWebProviderExtensions.cs b/src/Couchbase.AspNet/CouchbaseWebProviderExtensions.cs index e713327..96a58fd 100644 --- a/src/Couchbase.AspNet/CouchbaseWebProviderExtensions.cs +++ b/src/Couchbase.AspNet/CouchbaseWebProviderExtensions.cs @@ -6,14 +6,14 @@ namespace Couchbase.AspNet internal static class CouchbaseWebProviderExtensions { - //Currently not used - when project relies on MS.Logging then we can switch public static string PrefixIdentifier(this ICouchbaseWebProvider provider, string id) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException(nameof(id)); } - return provider.Prefix == null ? id : string.Concat(provider.Prefix, "-", id); + + return provider.Prefix != null && !id.StartsWith(provider.Prefix) ? string.Concat(provider.Prefix, "-", id) : id; } } } diff --git a/test/Couchbase.AspNet.UnitTests/CouchbaseWebProviderExtensionsTests.cs b/test/Couchbase.AspNet.UnitTests/CouchbaseWebProviderExtensionsTests.cs index 529484a..c981fb9 100644 --- a/test/Couchbase.AspNet.UnitTests/CouchbaseWebProviderExtensionsTests.cs +++ b/test/Couchbase.AspNet.UnitTests/CouchbaseWebProviderExtensionsTests.cs @@ -10,6 +10,7 @@ namespace Couchbase.AspNet.UnitTests { public class CouchbaseWebProviderExtensionsTests { + [InlineData("xxx", "xxx-mysession", "xxx-mysession")] [InlineData("xxx", "mysession", "xxx-mysession")] [InlineData(null, "mysession", "mysession")] [Theory]