Skip to content

Commit 46a1779

Browse files
committed
Oops. forgot the other NSID file
1 parent b642dcf commit 46a1779

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/idunno.AtProto/InternalStringExtensions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,32 @@ public static bool IsOnlyAsciiLetters(this string s)
6767

6868
return true;
6969
}
70+
71+
/// <summary>
72+
/// Gets a flag indicating whether the string only consists of ASCII letters and numbers.
73+
/// </summary>
74+
/// <param name="s">The string to check.</param>
75+
/// <returns>True if the string only consists of ASCII letters, otherwise false.</returns>
76+
public static bool IsOnlyAsciiLettersAndNumbers(this string s)
77+
{
78+
if (string.IsNullOrEmpty(s))
79+
{
80+
return true;
81+
}
82+
83+
foreach (char item in s)
84+
{
85+
if (item is >= 'A' and <= 'Z' or >= 'a' and <= 'z' or >= '0' and <= '9')
86+
{
87+
continue;
88+
}
89+
else
90+
{
91+
return false;
92+
}
93+
}
94+
95+
return true;
96+
}
7097
}
7198
}

0 commit comments

Comments
 (0)