< Summary

Information
Class: Elsa.Api.Client.Extensions.ApiResponseExtensions
Assembly: Elsa.Api.Client
File(s): /home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Extensions/ApiResponseExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 28
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetDownloadedFileNameOrDefault(...)0%4260%

File(s)

/home/runner/work/elsa-core/elsa-core/src/clients/Elsa.Api.Client/Extensions/ApiResponseExtensions.cs

#LineLine coverage
 1using Refit;
 2
 3namespace Elsa.Api.Client.Extensions;
 4
 5/// <summary>
 6/// Provides extension methods for <see cref="IApiResponse"/>.
 7/// </summary>
 8public static class ApiResponseExtensions
 9{
 10    /// <summary>
 11    /// Returns the downloaded file name or the specified default file name.
 12    /// </summary>
 13    public static string GetDownloadedFileNameOrDefault(this IApiResponse response, string defaultFileName = "download.b
 14    {
 015        var fileName = defaultFileName;
 16
 017        if (response.Headers.TryGetValues("content-disposition", out var contentDispositionHeader)) // Only available if
 18        {
 19            // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
 020            var values = contentDispositionHeader.ToList() ?? [];
 21
 022            if (values.Count >= 2)
 023                fileName = values[1].Split('=')[1];
 24        }
 25
 026        return fileName;
 27    }
 28}