Repository navigation
API Reference
Everything public is in the namespace IsImageUrlDotNet, in two static classes: ImageUrl (new in 2.0.0) and IsImageUrlDotNetLib (the 1.0.2 API, kept exactly). The verification program printed the surface of the net10.0 build by reflection:
static class IsImageUrlDotNet.ImageUrl [Extension]
IReadOnlyList<string> ImageExtensions { get; }
bool HasImageExtension(string url) [Extension]
Task<bool> IsImageUrlAsync(string url) [Extension]
Task<bool> IsImageUrlAsync(string url, CancellationToken cancellationToken) [Extension]
Task<bool> IsImageUrlAsync(string url, HttpClient httpClient) [Extension]
Task<bool> IsImageUrlAsync(string url, HttpClient httpClient, CancellationToken cancellationToken) [Extension]
static class IsImageUrlDotNet.IsImageUrlDotNetLib [Extension]
FSharpList<string> ImageFileExtensions { get; }
FSharpList<string> NonImageFileExtensions { get; }
bool IsImageUrl(string opt) [Extension] [Obsolete("IsImageUrl keeps 1.0.2's answers, bugs included. Use ImageUrl.HasImageExtension (offline) or ImageUrl.IsImageUrlAsync (http and https only).", error: false)]
The url parameters are annotated as nullable (string? to C#), so passing null compiles without a warning and answers false. The three builds in the package (net10.0, net462, netstandard2.0) have the same public methods; see the builds.
| Member | Since | Returns | Throws |
|---|---|---|---|
HasImageExtension(string? url) |
2.0.0 |
true when the path of the URL ends in one of ImageExtensions, compared without regard to case or culture |
never |
IsImageUrlAsync(string? url) |
2.0.0 | a task of true when the URL is http or https and has an image extension, or else when a GET answers 2xx with an image/* media type |
HttpRequestException, TaskCanceledException
|
IsImageUrlAsync(string? url, CancellationToken cancellationToken) |
2.0.0 | as above, cancellable | as above |
IsImageUrlAsync(string? url, HttpClient httpClient) |
2.0.0 | as above, through your client (its handler, proxy, timeout and headers) | as above, and ArgumentNullException for a null client |
IsImageUrlAsync(string? url, HttpClient httpClient, CancellationToken cancellationToken) |
2.0.0 | as above, cancellable | as above |
ImageExtensions |
2.0.0 | the 16 extensions, lower case, read-only | never |
All five methods are C# extension methods on string as well as static methods, and F# can call them either way. The exact rules are on How URLs are checked; every exception and its message is on Edge cases and errors.
ArgumentNullException for a null client is thrown by the call itself, before a task exists, so it escapes code that stores the task without awaiting it (example).
The overloads without a client use one shared HttpClient for the whole process. It times out after 10 seconds, sends the User-Agent IsImageUrlDotNet/2.0 (+https://github.com/m4bwav/IsImageUrlDotNet), follows no redirect by itself and uses the process's default proxy settings.
using IsImageUrlDotNet;
Console.WriteLine(string.Join(" ", ImageUrl.ImageExtensions));
Console.WriteLine(string.Join(" ", IsImageUrlDotNetLib.ImageFileExtensions));
Console.WriteLine(string.Join(" ", IsImageUrlDotNetLib.NonImageFileExtensions));prints:
png jpg jpeg gif raw bmp svg psd webp avif apng ico tif tiff heic heif
png jpg gif raw bmp svg jpeg psd
exe pdf html htm txt mp3 wav odp
ImageExtensions is an IReadOnlyList<string>. The two old lists are F# lists (Microsoft.FSharp.Collections.FSharpList<string>), which C# can enumerate like any IEnumerable<string>.
| Member | Since | Returns | Throws |
|---|---|---|---|
IsImageUrl(string opt) |
1.0.2 or earlier; obsolete since 2.0.0 | 1.0.2's answer on the runtime it runs on | whatever 1.0.2 threw: UriFormatException, WebException and more |
ImageFileExtensions |
1.0.2 or earlier | the eight extensions IsImageUrl treats as images without a request |
never |
NonImageFileExtensions |
1.0.2 or earlier | the eight it treats as not images without a request | never |
Versions before 1.0.2 were not examined. The obsolete attribute is a warning, not an error, so old code still builds. From C#, url.IsImageUrl() still works; from F#, only IsImageUrlDotNetLib.IsImageUrl url does. Its answers and requests match 1.0.2's in every recorded case (Versions and upgrading).
using IsImageUrlDotNet;
#pragma warning disable CS0618 // IsImageUrl is obsolete
Console.WriteLine("image.png".IsImageUrl());
Console.WriteLine("http://images.test/avatar".IsImageUrl());
#pragma warning restore CS0618prints:
True
True
The first answer came from the extension; the second made a request that the stand-in answered with image/png.
This file, with no #pragma:
using IsImageUrlDotNet;
var url = "http://images.test/avatar";
Console.WriteLine(url.IsImageUrl());
Console.WriteLine(await url.IsImageUrlAsync(default));gives:
warning CS0618: 'IsImageUrlDotNetLib.IsImageUrl(string?)' is obsolete: 'IsImageUrl keeps 1.0.2's answers, bugs included. Use ImageUrl.HasImageExtension (offline) or ImageUrl.IsImageUrlAsync (http and https only).'
error CS0121: The call is ambiguous between the following methods or properties: 'IsImageUrlDotNet.ImageUrl.IsImageUrlAsync(string?, System.Threading.CancellationToken)' and 'IsImageUrlDotNet.ImageUrl.IsImageUrlAsync(string?, System.Net.Http.HttpClient)'
default fits both CancellationToken and HttpClient. Pass CancellationToken.None, a real token or a client.
Read from each DLL's metadata in the published package:
lib/net10.0: 22016 bytes, 9 public methods, same public surface as the first; references FSharp.Core 6.0.0.0, netstandard 2.1.0.0, System.Collections 10.0.0.0, System.Net.Http 10.0.0.0, System.Net.Primitives 10.0.0.0, System.Net.Requests 10.0.0.0, System.Runtime 10.0.0.0
lib/net462: 22528 bytes, 9 public methods, same public surface as the first; references FSharp.Core 6.0.0.0, mscorlib 4.0.0.0, netstandard 2.0.0.0, System 4.0.0.0, System.Core 4.0.0.0, System.Net.Http 4.2.0.0
lib/netstandard2.0: 22016 bytes, 9 public methods, same public surface as the first; references FSharp.Core 6.0.0.0, netstandard 2.0.0.0
The package also ships XML documentation for each build, a README, an icon, and symbols in a separate snupkg.
This wiki describes IsImageUrlDotNet 2.0.0 and was last updated on 2026-09-29. The library is MIT licensed. Report problems in the issues. On NuGet: IsImageUrlDotNet.
Using it
The releases
Contributing
Elsewhere