diff --git a/src/Microsoft.AspNet.Http.Core/PathString.cs b/src/Microsoft.AspNet.Http.Core/PathString.cs index fe33adc2ba..cff6e1d3c6 100644 --- a/src/Microsoft.AspNet.Http.Core/PathString.cs +++ b/src/Microsoft.AspNet.Http.Core/PathString.cs @@ -227,6 +227,18 @@ namespace Microsoft.AspNet.Http return string.Concat(left, right.ToString()); } + /// + /// + /// The left parameter + /// The right parameter + /// The ToString combination of both values + public static string operator +(PathString left, string right) + { + // This overload exists to prevent the implicit string<->PathString converter from + // trying to call the PathString+PathString operator for things that are not path strings. + return string.Concat(left.ToString(), right); + } + /// /// Operator call through to Add /// diff --git a/test/Microsoft.AspNet.Http.Core.Tests/PathStringTests.cs b/test/Microsoft.AspNet.Http.Core.Tests/PathStringTests.cs index d4a5502cbb..720b3b0814 100644 --- a/test/Microsoft.AspNet.Http.Core.Tests/PathStringTests.cs +++ b/test/Microsoft.AspNet.Http.Core.Tests/PathStringTests.cs @@ -63,6 +63,12 @@ namespace Microsoft.AspNet.Http var result = scheme + "://" + host + pathBase + path + query + fragment; Assert.Equal("http://localhost:80/base/path?query#frag", result); + + result = pathBase + path + query + fragment; + Assert.Equal("/base/path?query#frag", result); + + result = path + "text"; + Assert.Equal("/pathtext", result); } } }