Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit fcd6a49

Browse files
committed
Unify ConvertFromString
1 parent 6893517 commit fcd6a49

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Microsoft.AspNetCore.Http.Abstractions/PathString.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ public override int GetHashCode()
443443
/// </summary>
444444
/// <param name="s"></param>
445445
public static implicit operator PathString(string s)
446-
{
447-
return new PathString(s);
448-
}
449446

450447
/// <summary>
451448
/// Implicitly calls ToString().
@@ -455,6 +452,9 @@ public static implicit operator string(PathString path)
455452
{
456453
return path.ToString();
457454
}
455+
456+
internal static PathString ConvertFromString(string s)
457+
=> string.IsNullOrEmpty(s) ? new PathString(s) : FromUriComponent(s);
458458
}
459459

460460
internal class PathStringConverter : TypeConverter
@@ -466,7 +466,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT
466466

467467
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
468468
=> value is string
469-
? new PathString((string)value)
469+
? PathString.ConvertFromString((string)value)
470470
: base.ConvertFrom(context, culture, value);
471471

472472
public override object ConvertTo(ITypeDescriptorContext context,

0 commit comments

Comments
 (0)