Add PathString+string operator to prevent too much string<->PathString implicit conversion.
This commit is contained in:
parent
86bd393d3d
commit
65e57d28f3
|
|
@ -227,6 +227,18 @@ namespace Microsoft.AspNet.Http
|
|||
return string.Concat(left, right.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="left">The left parameter</param>
|
||||
/// <param name="right">The right parameter</param>
|
||||
/// <returns>The ToString combination of both values</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operator call through to Add
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue