Skip to content

Commit 18df1ac

Browse files
committed
Changing access to the CallbackScriptTagHelperComponent to internal as there is not really a reason to make it accessible to the public.
Added a null check to the constructor.
1 parent ca3d8a3 commit 18df1ac

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ReCaptcha/TagHelpers/CallbackScriptTagHelperComponent.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
2+
using System.Runtime.CompilerServices;
23
using Microsoft.AspNetCore.Razor.TagHelpers;
34

5+
[assembly: InternalsVisibleTo("ReCaptcha.Tests")]
46
namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
57
{
68
/// <summary>
@@ -9,20 +11,20 @@ namespace Griesoft.AspNetCore.ReCaptcha.TagHelpers
911
/// <remarks>
1012
/// The callback script is used as a default callback function to submit a form after a reCAPTCHA challenge was successful.
1113
/// </remarks>
12-
public class CallbackScriptTagHelperComponent : TagHelperComponent
14+
internal class CallbackScriptTagHelperComponent : TagHelperComponent
1315
{
1416
private readonly string _formId;
1517

16-
/// <summary>
17-
///
18-
/// </summary>
19-
/// <param name="formId"></param>
2018
public CallbackScriptTagHelperComponent(string formId)
2119
{
20+
if (string.IsNullOrEmpty(formId))
21+
{
22+
throw new ArgumentNullException(nameof(formId));
23+
}
24+
2225
_formId = formId;
2326
}
2427

25-
/// <inheritdoc />
2628
public override void Process(TagHelperContext context, TagHelperOutput output)
2729
{
2830
if (string.Equals(context.TagName, "body", StringComparison.OrdinalIgnoreCase))
@@ -31,7 +33,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
3133
}
3234
}
3335

34-
private static string CallbackScript(string formId)
36+
public static string CallbackScript(string formId)
3537
{
3638
// Append the formId to the function name in case that multiple recaptcha tags are added in a document.
3739
return $"<script>function submit{formId}(token){{document.getElementById('{formId}').submit();}}</script>";

0 commit comments

Comments
 (0)