Skip to content

Commit b657371

Browse files
committed
Add url validation and whitespace refactoring
1 parent 7afb073 commit b657371

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

SSLLWrapper/Domain/UrlValidation.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@ public bool IsValid(string url)
1616

1717
return valid;
1818
}
19+
20+
public string Format(string url)
21+
{
22+
if (!url.EndsWith("/"))
23+
{
24+
url = url + "/";
25+
}
26+
27+
return url;
28+
}
1929
}
2030
}

SSLLWrapper/SSLLService.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal SSLLService(string apiUrl, IApiProvider apiProvider)
5353
_requestModelFactory = new RequestModelFactory();
5454
_urlValidation = new UrlValidation();
5555
_responsePopulation = new ResponsePopulation();
56-
ApiUrl = apiUrl;
56+
ApiUrl = _urlValidation.Format(apiUrl);
5757
}
5858

5959
#endregion
@@ -67,10 +67,8 @@ public Info Info()
6767

6868
try
6969
{
70-
// Making Api request and gathering response
70+
// Making Api request and binding result to model
7171
var webResponse = _apiProvider.MakeGetRequest(requestModel);
72-
73-
// Binding result to model
7472
infoModel = _responsePopulation.InfoModel(webResponse, infoModel);
7573

7674
if (infoModel.engineVersion != null)
@@ -114,10 +112,8 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
114112

115113
try
116114
{
117-
// Making Api request and gathering response
115+
// Making Api request and binding result to model
118116
var webResponse = _apiProvider.MakeGetRequest(requestModel);
119-
120-
// Binding result to model
121117
analyzeModel = _responsePopulation.AnalyzeModel(webResponse, analyzeModel);
122118
}
123119
catch (Exception ex)
@@ -155,10 +151,8 @@ public Endpoint GetEndpointData(string host, string s, FromCache fromCache)
155151

156152
try
157153
{
158-
// Making Api request and gathering response
154+
// Making Api request and binding result to model
159155
var webResponse = _apiProvider.MakeGetRequest(requestModel);
160-
161-
// Binding result to model
162156
endpointModel = _responsePopulation.EndpointModel(webResponse, endpointModel);
163157
}
164158
catch (Exception ex)
@@ -176,16 +170,12 @@ public Endpoint GetEndpointData(string host, string s, FromCache fromCache)
176170
public StatusCodes GetStatusCodes()
177171
{
178172
var statusCodesModel = new StatusCodes();
179-
180-
// Building request model
181173
var requestModel = _requestModelFactory.NewStatusCodesRequestModel(ApiUrl, "getStatusCodes");
182174

183175
try
184176
{
185-
// Making Api request and gathering response
177+
// Making Api request and binding result to model
186178
var webResponse = _apiProvider.MakeGetRequest(requestModel);
187-
188-
// Binding result to model
189179
statusCodesModel = _responsePopulation.StatusCodesModel(webResponse, statusCodesModel);
190180
}
191181
catch (Exception ex)

0 commit comments

Comments
 (0)