diff --git a/Web.HtmlSanitizer/HtmlSanitizer.cs b/Web.HtmlSanitizer/HtmlSanitizer.cs
index 56d772d..0ba98fe 100644
--- a/Web.HtmlSanitizer/HtmlSanitizer.cs
+++ b/Web.HtmlSanitizer/HtmlSanitizer.cs
@@ -110,7 +110,7 @@ public HtmlSanitizer()
///
///
[Obsolete("This method has been deprecated in favor of the UrlCheckerAttributeSanitizer.")]
- public static bool AttributeUrlCheck(HtmlAttribute attribute) => new UrlCheckerAttributeSanitizer() { AllowedUriSchemes = defaultAllowedUriSchemes }.AttributeUrlCheck(attribute);
+ public static bool AttributeUrlCheck(HtmlAttribute attribute) => new UrlCheckerAttributeSanitizer().AttributeUrlCheck(attribute);
///
/// Equal to the SimpleHtml5Sanitizer but allows html and body declarations.
diff --git a/Web.HtmlSanitizer/UrlCheckerAttributeSanitizer.cs b/Web.HtmlSanitizer/UrlCheckerAttributeSanitizer.cs
index 884f66d..ff56cc1 100644
--- a/Web.HtmlSanitizer/UrlCheckerAttributeSanitizer.cs
+++ b/Web.HtmlSanitizer/UrlCheckerAttributeSanitizer.cs
@@ -12,15 +12,20 @@ public class UrlCheckerAttributeSanitizer : IHtmlAttributeSanitizer
///
/// Collection of the allowed URI schemes.
///
- public string[] AllowedUriSchemes { get; internal set; }
+ public string[] AllowedUriSchemes { get; }
- ///
- /// Checks if the attribute contains a valid URL.
- ///
- ///
- ///
- ///
- public virtual SanitizerOperation SanitizeAttribute(HtmlAttribute attribute, HtmlSanitizerTagRule tagRule) =>
+ public UrlCheckerAttributeSanitizer(string[] allowedUriSchemes)
+ {
+ AllowedUriSchemes = allowedUriSchemes ?? HtmlSanitizer.defaultAllowedUriSchemes;
+ }
+
+ ///
+ /// Checks if the attribute contains a valid URL.
+ ///
+ ///
+ ///
+ ///
+ public virtual SanitizerOperation SanitizeAttribute(HtmlAttribute attribute, HtmlSanitizerTagRule tagRule) =>
// Check the url. We assume that there's no use in keeping for example a link tag without a href, so flatten the tag on failure.
!AttributeUrlCheck(attribute) ? SanitizerOperation.FlattenTag : SanitizerOperation.DoNothing;
@@ -62,7 +67,7 @@ public static class UrlCheckerAttributeSanitizerFluentHelper
///
public static HtmlSanitizerTagRule CheckAttributeUrl(this HtmlSanitizerTagRule rule, string attribute, string[] allowedUriSchemes = null)
{
- rule.AttributeChecks.Add(attribute, new UrlCheckerAttributeSanitizer() { AllowedUriSchemes = allowedUriSchemes ?? HtmlSanitizer.defaultAllowedUriSchemes });
+ rule.AttributeChecks.Add(attribute, new UrlCheckerAttributeSanitizer(allowedUriSchemes));
return rule;
}
}