generated from NetCoreTemplates/blazor-vue
-
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.
Add initial support for notifications
- Loading branch information
Showing
23 changed files
with
865 additions
and
72 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
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,31 @@ | ||
using ServiceStack.Text; | ||
|
||
namespace MyApp.Data; | ||
|
||
public static class StringExtensions | ||
{ | ||
static bool IsUserNameChar(char c) => c == '-' || (char.IsLetterOrDigit(c) && char.IsLower(c)); | ||
|
||
public static List<string> FindUserNameMentions(this string text) | ||
{ | ||
var to = new List<string>(); | ||
var s = text.AsSpan(); | ||
s.AdvancePastChar('@'); | ||
while (s.Length > 0) | ||
{ | ||
var i = 0; | ||
while (IsUserNameChar(s[i])) | ||
{ | ||
if (++i >= s.Length) | ||
break; | ||
} | ||
var candidate = i > 2 ? s[..i].ToString() : ""; | ||
if (candidate.Length > 1) | ||
{ | ||
to.Add(candidate); | ||
} | ||
s = s.Advance(i).AdvancePastChar('@'); | ||
} | ||
return to; | ||
} | ||
} |
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
Oops, something went wrong.