|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
| 3 | +#nullable disable |
3 | 4 |
|
4 | 5 | using Amazon.S3; |
5 | 6 | using Amazon.S3.Model; |
@@ -28,7 +29,7 @@ private readonly Dictionary<string, AmazonS3Client> buckets |
28 | 29 | = new(); |
29 | 30 |
|
30 | 31 | private readonly AWSS3StorageImageProviderOptions storageOptions; |
31 | | - private Func<HttpContext, bool>? match; |
| 32 | + private Func<HttpContext, bool> match; |
32 | 33 |
|
33 | 34 | /// <summary> |
34 | 35 | /// Contains various helper methods based on the current configuration. |
@@ -69,23 +70,17 @@ public bool IsValidRequest(HttpContext context) |
69 | 70 | => this.formatUtilities.TryGetExtensionFromUri(context.Request.GetDisplayUrl(), out _); |
70 | 71 |
|
71 | 72 | /// <inheritdoc /> |
72 | | - public async Task<IImageResolver?> GetAsync(HttpContext context) |
| 73 | + public async Task<IImageResolver> GetAsync(HttpContext context) |
73 | 74 | { |
74 | 75 | // Strip the leading slash and bucket name from the HTTP request path and treat |
75 | 76 | // the remaining path string as the key. |
76 | 77 | // Path has already been correctly parsed before here. |
77 | 78 | string bucketName = string.Empty; |
78 | | - IAmazonS3? s3Client = null; |
| 79 | + IAmazonS3 s3Client = null; |
79 | 80 |
|
80 | 81 | // We want an exact match here to ensure that bucket names starting with |
81 | 82 | // the same prefix are not mixed up. |
82 | | - string? path = context.Request.Path.Value?.TrimStart(SlashChars); |
83 | | - |
84 | | - if (path is null) |
85 | | - { |
86 | | - return null; |
87 | | - } |
88 | | - |
| 83 | + string path = context.Request.Path.Value.TrimStart(SlashChars); |
89 | 84 | int index = path.IndexOfAny(SlashChars); |
90 | 85 | string nameToMatch = index != -1 ? path.Substring(0, index) : path; |
91 | 86 |
|
@@ -126,13 +121,7 @@ private bool IsMatch(HttpContext context) |
126 | 121 | { |
127 | 122 | // Only match loosly here for performance. |
128 | 123 | // Path matching conflicts should be dealt with by configuration. |
129 | | - string? path = context.Request.Path.Value?.TrimStart(SlashChars); |
130 | | - |
131 | | - if (path is null) |
132 | | - { |
133 | | - return false; |
134 | | - } |
135 | | - |
| 124 | + string path = context.Request.Path.Value.TrimStart(SlashChars); |
136 | 125 | foreach (string bucket in this.buckets.Keys) |
137 | 126 | { |
138 | 127 | if (path.StartsWith(bucket, StringComparison.OrdinalIgnoreCase)) |
@@ -177,7 +166,7 @@ private static async Task<KeyExistsResult> KeyExists(IAmazonS3 s3Client, string |
177 | 166 | } |
178 | 167 | } |
179 | 168 |
|
180 | | - private readonly record struct KeyExistsResult(GetObjectMetadataResponse? Metadata) |
| 169 | + private readonly record struct KeyExistsResult(GetObjectMetadataResponse Metadata) |
181 | 170 | { |
182 | 171 | public bool Exists => this.Metadata is not null; |
183 | 172 | } |
|
0 commit comments