Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
FBoucher committed Jul 23, 2020
2 parents bc7118e + c189ffc commit 82644e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public async Task<ShortUrlEntity> 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;
Expand Down
7 changes: 7 additions & 0 deletions src/shortenerTools/UrlShortener/UrlShortener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public static async Task<HttpResponseMessage> 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))
{
Expand Down
7 changes: 7 additions & 0 deletions src/shortenerTools/UrlUpdate/UrlUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public static async Task<HttpResponseMessage> 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))
{
Expand Down

0 comments on commit 82644e1

Please sign in to comment.