Skip to content

Commit

Permalink
Merge pull request #112 from Hedlund01/Issue_48
Browse files Browse the repository at this point in the history
Add Content validation on URL create and Update
  • Loading branch information
FBoucher authored Jul 23, 2020
2 parents d0ceb16 + 59b216b commit 2384c1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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 2384c1d

Please sign in to comment.