Skip to content

Commit 73db68b

Browse files
committed
Removing redirect response / Fixes
1 parent 95c6a71 commit 73db68b

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

PostBlogComment.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,12 @@ public async Task<IActionResult> Run(
7777
return new BadRequestErrorMessageResult(string.Join(NewLine, errors));
7878
}
7979

80-
if (Uri.TryCreate(form["redirect"], Absolute, out var redirectUri))
81-
{
82-
return new RedirectResult(redirectUri.ToString());
83-
}
84-
8580
return new OkResult();
8681
}
8782

8883
private bool IsNotCommentFromCorrectSite(IFormCollection form)
8984
{
90-
if (!Uri.TryCreate(form["comment-site"], Absolute, out var postedCommentSite))
85+
if (!Uri.TryCreate(form["commentSite"], Absolute, out var postedCommentSite))
9186
{
9287
return true;
9388
}
@@ -129,7 +124,7 @@ private async Task<CreateFileRequest> CreateCommentFile(
129124
Reference prBranch,
130125
Comment comment)
131126
{
132-
var commitMessage = $"Comment by {comment.name} on {comment.post_id}";
127+
var commitMessage = $"Comment by {comment.name} on {comment.PostId}";
133128
var commentContent = new SerializerBuilder().Build().Serialize(comment);
134129
var commenterEmail = comment.email ?? _committerFallbackEmail;
135130

@@ -138,7 +133,7 @@ private async Task<CreateFileRequest> CreateCommentFile(
138133
Committer = new Committer(comment.name, commenterEmail, comment.date)
139134
};
140135

141-
var commentFilePath = $"_data/comments/{comment.post_id}/{comment.id}.yml";
136+
var commentFilePath = $"_data/comments/{comment.PostId}/{comment.id}.yml";
142137

143138
await _githubRepoClient.Content.CreateFile(repo.Id, commentFilePath, fileRequest);
144139

@@ -171,27 +166,27 @@ private class Comment
171166
private static readonly ParameterInfo[] _ctorParameters = _ctor.GetParameters();
172167

173168
// Valid characters when mapping from the blog post slug to a file path
174-
private static readonly Regex _validPathChars = new Regex(@"[^a-zA-Z0-9-]", Compiled);
169+
private static readonly Regex _invalidPathChars = new Regex(@"[^a-zA-Z0-9-]", Compiled);
175170
private static readonly Regex _emailMatcher = new Regex(@"^[^@\s]+@[^@\s]+\.[^@\s]+$", Compiled);
176171

177172
public Comment(
178-
string post_id,
173+
string postId,
179174
string message,
180175
string name,
181176
string email = null,
182177
Uri url = null,
183178
string avatar = null)
184179
{
185-
this.post_id = _validPathChars.Replace(post_id, "-");
180+
PostId = _invalidPathChars.Replace(postId, "-");
186181
this.message = message;
187182
this.name = name;
188183
this.email = email;
189184
this.url = url;
190185

191186
date = DateTime.UtcNow;
192-
id = new { this.post_id, this.name, this.message, this.date }.GetHashCode().ToString("x8");
187+
id = new { post_id = PostId, name, message, date }.GetHashCode().ToString("x8");
193188

194-
if (Uri.TryCreate(avatar, Absolute, out Uri avatarUrl))
189+
if (Uri.TryCreate(avatar, Absolute, out var avatarUrl))
195190
{
196191
this.avatar = avatarUrl;
197192
}
@@ -238,7 +233,7 @@ public static bool TryCreate(
238233

239234
private static object GetParameterValue(IFormCollection form, ParameterInfo parameter)
240235
{
241-
var value = form[parameter.Name];
236+
var value = form[parameter.Name].ToString();
242237

243238
if (string.IsNullOrWhiteSpace(value))
244239
{
@@ -255,7 +250,7 @@ private static object GetParameterFallbackValue(ParameterInfo parameter)
255250
#endregion
256251

257252
[YamlIgnore]
258-
public string post_id { get; }
253+
public string PostId { get; }
259254

260255
public string id { get; }
261256

0 commit comments

Comments
 (0)