Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,12 @@ private string GetParentUrl(string baseUri, string blobPrefix)

private static string EscapeUri(string stringToEscape)
{
#pragma warning disable SYSLIB0013 // Type or member is obsolete
// Unfortunately, no replacement for this call. We should consider to remove this call at all.
return Uri.EscapeUriString(stringToEscape);
#pragma warning restore SYSLIB0013 // Type or member is obsolete
// espace only file name because Uri.EscapeDataString() escapes slashes, which we don't want
var fileName = Path.GetFileName(stringToEscape);
var blobPath = string.IsNullOrEmpty(fileName) ? stringToEscape : stringToEscape.Replace(fileName, string.Empty);
var escapedFileName = Uri.EscapeDataString(fileName);

return $"{blobPath}{escapedFileName}";
}

private BlobContainerClient GetBlobContainer(string name)
Expand Down Expand Up @@ -477,12 +479,8 @@ private BlobInfo ConvertBlobToBlobInfo(BlobClient blob, BlobProperties props)

private BlobInfo ConvertBlobToBlobInfo(BlobItem blob, string baseUri)
{
// espace only file name because Uri.EscapeDataString() escapes slashes, which we don't want
var fileName = Path.GetFileName(blob.Name);
var blobPath = string.IsNullOrEmpty(fileName) ? blob.Name : blob.Name.Replace(fileName, string.Empty);
var escapedFileName = Uri.EscapeDataString(fileName);

var absoluteUrl = UrlHelperExtensions.Combine(baseUri, $"{blobPath}{escapedFileName}");
var absoluteUrl = UrlHelperExtensions.Combine(baseUri, EscapeUri(blob.Name));
var relativeUrl = absoluteUrl.Replace(EscapeUri(_blobServiceClient.Uri.ToString()), string.Empty);
var contentType = MimeTypeResolver.ResolveContentType(fileName);

Expand Down