-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sanitized typeName prior to using it. (#30) * Added release notes and updated NuGet packages. (#31)
- Loading branch information
1 parent
0097c7d
commit 5fa11ee
Showing
10 changed files
with
209 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Crud.Api.Constants | ||
{ | ||
public static class Default | ||
{ | ||
public const String TypeName = "DefaultTypeName"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Crud.Api.Services | ||
{ | ||
public interface ISanitizerService | ||
{ | ||
String SanitizeTypeName(String? className); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.RegularExpressions; | ||
using Crud.Api.Constants; | ||
|
||
namespace Crud.Api.Services | ||
{ | ||
public class SanitizerService : ISanitizerService | ||
{ | ||
public String SanitizeTypeName(String? typeName) | ||
{ | ||
if (String.IsNullOrWhiteSpace(typeName)) | ||
return Default.TypeName; | ||
|
||
string sanitizedTypeName = Regex.Replace(typeName, @"[^@\w]", String.Empty); | ||
|
||
if (sanitizedTypeName.Length == 0) | ||
return Default.TypeName; | ||
|
||
return sanitizedTypeName; | ||
} | ||
} | ||
} |
Oops, something went wrong.