diff --git a/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs b/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs index 7ac81af9..36efec80 100644 --- a/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs +++ b/src/adminTools/adminBlazorWebsite/src/Data/UrlShortenerService.cs @@ -116,7 +116,7 @@ public async Task ArchiveShortUrl(ShortUrlEntity archivedUrl) CancellationToken cancellationToken; using (var client = new HttpClient()) - using (var request = new HttpRequestMessage(HttpMethod.Delete, url)) + using (var request = new HttpRequestMessage(HttpMethod.Post, url)) using (var httpContent = CreateHttpContent(archivedUrl)) { request.Content = httpContent; diff --git a/src/shortenerTools/UrlShortener/UrlShortener.cs b/src/shortenerTools/UrlShortener/UrlShortener.cs index 93a312f6..2d4156f9 100644 --- a/src/shortenerTools/UrlShortener/UrlShortener.cs +++ b/src/shortenerTools/UrlShortener/UrlShortener.cs @@ -56,6 +56,13 @@ public static async Task Run( return req.CreateResponse(HttpStatusCode.NotFound); } + + // If the Url parameter only contains whitespaces or is empty return with BadRequest. + if (string.IsNullOrWhiteSpace(input.Url)) + { + return req.CreateErrorResponse(HttpStatusCode.BadRequest, "The url parameter can not be empty."); + } + // Validates if input.url is a valid aboslute url, aka is a complete refrence to the resource, ex: http(s)://google.com if (!Uri.IsWellFormedUriString(input.Url, UriKind.Absolute)) { diff --git a/src/shortenerTools/UrlUpdate/UrlUpdate.cs b/src/shortenerTools/UrlUpdate/UrlUpdate.cs index 9aef71f0..848c4015 100644 --- a/src/shortenerTools/UrlUpdate/UrlUpdate.cs +++ b/src/shortenerTools/UrlUpdate/UrlUpdate.cs @@ -62,6 +62,13 @@ public static async Task Run( return req.CreateResponse(HttpStatusCode.NotFound); } + + // If the Url parameter only contains whitespaces or is empty return with BadRequest. + if (string.IsNullOrWhiteSpace(input.Url)) + { + return req.CreateErrorResponse(HttpStatusCode.BadRequest, "The url parameter can not be empty."); + } + // Validates if input.url is a valid aboslute url, aka is a complete refrence to the resource, ex: http(s)://google.com if (!Uri.IsWellFormedUriString(input.Url, UriKind.Absolute)) {