@@ -30,19 +30,20 @@ public static class FileUri
3030 /// </summary>
3131 /// <param name="fileName">The fully-qualified file name.</param>
3232 /// <param name="settings">The encoding settings.</param>
33- /// <returns><paramref name="fileName"/> as <see cref="Uri"/>.</returns>
33+ /// <returns><paramref name="fileName"/> as URI. The return value can be passed to <see cref="Uri(string) "/> constructor .</returns>
3434 /// <exception cref="ArgumentException"><paramref name="fileName"/> is not fully-qualified.</exception>
35- public static Uri Encode ( ReadOnlySpan < char > fileName , TextEncoderSettings ? settings = null )
35+ public static string Encode ( ReadOnlySpan < char > fileName , TextEncoderSettings ? settings = null )
3636 {
3737 ThrowIfPartiallyQualified ( fileName ) ;
3838 var encoder = settings is null ? UrlEncoder . Default : UrlEncoder . Create ( settings ) ;
3939 var maxLength = GetMaxEncodedLengthCore ( fileName , encoder ) ;
4040 using var buffer = ( uint ) maxLength <= ( uint ) SpanOwner < char > . StackallocThreshold
4141 ? stackalloc char [ maxLength ]
4242 : new SpanOwner < char > ( maxLength ) ;
43-
44- TryEncodeCore ( fileName , encoder , buffer . Span , out var writtenCount ) ;
45- return new ( buffer . Span . Slice ( 0 , writtenCount ) . ToString ( ) , UriKind . Absolute ) ;
43+
44+ return TryEncodeCore ( fileName , encoder , buffer . Span , out var writtenCount )
45+ ? buffer . Span . Slice ( 0 , writtenCount ) . ToString ( )
46+ : string . Empty ;
4647 }
4748
4849 /// <summary>
0 commit comments